Very inconsistent (read) speed on UFS2
Lev Serebryakov
lev at serebryakov.spb.ru
Wed Aug 31 07:38:38 UTC 2011
Hello, Bob.
You wrote 31 августа 2011 г., 2:40:07:
>>> I'll try this experiment with mmap() and touching every 4096-th byte of
>>> mapped memory instead of read(2).
>> Strange enough, it gives only 40-50MiB/s and results are very
>> consistent.
>>
>> It really surprise me. I didn't think, that there will be so much
>> difference, I was sure, that it will be almost equivalent speed.
> FreeBSD does not seem to default to sequential read-ahead when memory
> mapping is used with sequential page access. Try using madvise()
> with the MADV_SEQUENTIAL option and see if it helps.
It were results with MADV_SEQUENTIAL. Code looks like this: (error
checking is skipped here, but not in real code, of course):
fd = open(fileName, O_RDONLY | O_DIRECT);
buf = mmap(NULL, fileSize, PROT_READ, 0, fd, 0);
madvise(buf, fileSize, MADV_SEQUENTIAL);
gettimeofday(&start, NULL);
for (rd = 0; rd < fileSize; rd += 4096)
c = buf[rd];
gettimeofday(&end, NULL);
munmap(buf, fileSize);
close(fd);
> There are also MADV_WILLNEED, MADV_DONTNEED, and MADV_FREE. Careful
> use of these options can help performance quite a lot when data is
> large compared to memory.
It is too complex for simple linear read test :)
--
// Black Lion AKA Lev Serebryakov <lev at serebryakov.spb.ru>
More information about the freebsd-fs
mailing list