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
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);
for (rd = 0; rd < fileSize; rd += 4096)
c = buf[rd];
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 <le...@serebryakov.spb.ru>
free...@freebsd.org mailing list
To unsubscribe, send any mail to "free...@freebsd.org"