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

Peter Jeremy peterjeremy at optushome.com.au
Fri Mar 24 08:50:20 UTC 2006


On Thu, 2006-Mar-23 15:16:11 -0800, Matthew Dillon wrote:
>    FreeBSD.  To determine which of the two is more likely, you have to
>    run a smaller data set (like 600MB of data on a system with 1GB of ram),
>    and use the unmount/mount trick to clear the cache before each grep test.

On an amd64 system running about 6-week old -stable, both behave
pretty much identically.  In both cases, systat reports that the disk
is about 96% busy whilst loading the cache.  In the cache case, mmap
is significantly faster.

The test data is 2 copies of OOo_2.0.2rc2_src.tar.gz concatenated.

turion% ls -l /6_i386/var/tmp/test
-rw-r--r--  1 peter  wheel  586333684 Mar 24 19:24 /6_i386/var/tmp/test
turion% /usr/bin/time -l grep dfhfhdsfhjdsfl /6_i386/var/tmp/test
       21.69 real         0.16 user         0.68 sys
      1064  maximum resident set size
        82  average shared memory size
        95  average unshared data size
       138  average unshared stack size
       119  page reclaims
         0  page faults
         0  swaps
      4499  block input operations
         0  block output operations
         0  messages sent
         0  messages received
         0  signals received
      4497  voluntary context switches
      3962  involuntary context switches

[umount/remount /6_i386/var]

turion% /usr/bin/time -l grep --mmap dfhfhdsfhjdsfl /6_i386/var/tmp/test
       21.68 real         0.41 user         0.51 sys
      1068  maximum resident set size
        80  average shared memory size
        93  average unshared data size
       136  average unshared stack size
     17836  page reclaims
     18081  page faults
         0  swaps
        23  block input operations
         0  block output operations
         0  messages sent
         0  messages received
         0  signals received
     18105  voluntary context switches
       169  involuntary context switches

The speed gain with mmap is clearly evident when the data is cached and
the CPU clock wound right down (99MHz ISO 2200MHz):

turion% /usr/bin/time grep --mmap dfhfhdsfhjdsfl /6_i386/var/tmp/test
       12.15 real         7.98 user         2.95 sys
turion% /usr/bin/time grep --mmap dfhfhdsfhjdsfl /6_i386/var/tmp/test
       12.28 real         7.92 user         2.94 sys
turion% /usr/bin/time grep --mmap dfhfhdsfhjdsfl /6_i386/var/tmp/test
       13.16 real         8.03 user         2.89 sys
turion% /usr/bin/time grep dfhfhdsfhjdsfl /6_i386/var/tmp/test 
       17.09 real         6.37 user         8.92 sys
turion% /usr/bin/time grep dfhfhdsfhjdsfl /6_i386/var/tmp/test
       17.36 real         6.35 user         9.37 sys
turion% /usr/bin/time grep dfhfhdsfhjdsfl /6_i386/var/tmp/test
       17.54 real         6.37 user         9.39 sys

-- 
Peter Jeremy


More information about the freebsd-stable mailing list