Reading via mmap stinks (Re: weird bugs with mmap-ing via NFS)

Mikhail Teterin mi+mx at aldan.algebra.com
Thu Mar 23 21:26:40 UTC 2006


четвер 23 березень 2006 15:48, Matthew Dillon Ви написали:
>     Well, I don't know about FreeBSD, but both grep cases work just fine on
>     DragonFly.

Yes, they both do work fine, but time gives very different stats for each. In 
my experiments, the total CPU time is noticably less with mmap, but the 
elapsed time is (much) greater. Here are results from FreeBSD-6.1/amd64 -- 
notice the large number of page faults, because the system does not try to 
preload file in the mmap case as it does in the read case:

	time fgrep meowmeowmeow /home/oh.0.dump
	2.167u 7.739s 1:25.21 11.6%     70+3701k 23663+0io 6pf+0w
	time fgrep --mmap  meowmeowmeow /home/oh.0.dump
	1.552u 7.109s 2:46.03 5.2%      18+1031k 156+0io 106327pf+0w

Use a big enough file to bust the memory caching (oh.0.dump above is 2.9Gb), 
I'm sure, you will have no problems reproducing this result.

>     I can't test mzip.c because I don't see the compression 
>     library you are calling (maybe that's a FreeBSD thing).

The program uses -lz and -lbz2 -- both are parts of FreeBSD since before the 
unfortunate fork of DF. The following should work for you:

	make -f bsd.prog.mk LDADD="-lz -lbz2" PROG=mzip mzip

Yours,

	-mi


More information about the freebsd-stable mailing list