Hello.
This comes from Debian's [http://bugs.debian.org/478437 bug#478437] and [http://bugs.debian.org/472059 bug#472059].
It seems that with PRUNE_BIND_MOUNTS="yes", a stat call on /etc/mtab is done per directory that gets scanned. One one of the submitter's system, this makes updatedb 10 seconds of wall time slower.
The same submitter says, "It is caused, I think, by glibc checking that its cached /etc/mtab is up-to-date each time a *mntent() function is called. Perhaps it would be worth caching the mntent values in updatedb?".
Thanks.
Thanks for your report.
This happens in src/updatedb.c:is_bind_mount(). Some bind mounts can not be identified by comparing st_dev. The only way to identify them is to check the path is not one of known bind mount paths, and to make sure the list of known bind mount paths is current.
src/updatedb.c:is_bind_mount()
st_dev
Keeping the list current is important because updatedb can run for several minutes and it could unnecessarily overload the network if it did not exclude a mount point that had been mounted after updatedb was started.
updatedb
Refreshing the list only once per second (or other small interval) does not help because checking the time interval would require as many system calls as checking whether /etc/mtab has changed. Refreshing the list only once per e.g. 100 directories scanned would decrease the number of system calls, but it would make updatedb unreliable: if one directory from the "batch" of 100 directories were an unavailable NFS mount, the time to scan the "batch" could be many minutes, and bind mounts mounted in the meantime over other directories in the batch would not be noticed.
/etc/mtab
The mlocate implementation does focus on performance, but correctness always comes first. The overhead measured in [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=478437 Debian #478437] is less than 3% of real time, which I consider quite acceptable.
mlocate