aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2020-10-14 12:28:41 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2020-10-14 12:28:41 +0000
commit6e4162c60c8dc2647bcfa512b889934806939ce8 (patch)
tree504d82471c9edd1083186f5fef074dc216f0af78 /tools
parent472d183268eb4ab581c55d8277ec6d84871c78a7 (diff)
downloadsrc-6e4162c60c8dc2647bcfa512b889934806939ce8.tar.gz
src-6e4162c60c8dc2647bcfa512b889934806939ce8.zip
install(1): Avoid unncessary fstatfs() calls and use mmap() based on size
According to git blame the trymmap() function was added in 1996 to skip mmap() calls for NFS file systems. However, nowadays mmap() should be perfectly safe even on NFS. Importantly, onl ufs and cd9660 file systems were whitelisted so we don't use mmap() on ZFS. It also prevents the use of mmap() when bootstrapping from macOS/Linux since on those systems the trymmap() function was always returning zero due to the missing MFSNAMELEN define. This change keeps the trymmap() function but changes it to check whether using mmap() can reduce the number of system calls that are required. Using mmap() only reduces the number of system calls if we need multiple read() syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is more expensive than read() so this sets the threshold at 4 fewer syscalls. Additionally, for larger file size mmap() can significantly increase the number of page faults, so avoid it in that case. It's unclear whether using mmap() is ever faster than a read with an appropriate buffer size, but this change at least removes two unnecessary system calls for every file that is installed. Reviewed By: markj Differential Revision: https://reviews.freebsd.org/D26041
Notes
Notes: svn path=/head/; revision=366697
Diffstat (limited to 'tools')
0 files changed, 0 insertions, 0 deletions