Date: Thu, 15 Oct 2020 09:14:51 +0100 From: Alexander Richardson <arichardson@freebsd.org> To: Enji Cooper <yaneurabeya@gmail.com> Cc: src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org> Subject: Re: svn commit: r366697 - head/usr.bin/xinstall Message-ID: <CA%2BZ_v8q7p5wnK4OH_SRBYJzocaP0eTpG3_b2Kifwb7EMnZSyqw@mail.gmail.com> In-Reply-To: <463B3544-BF7B-49FF-82EA-ECB5D8FBB17B@gmail.com> References: <202010141228.09ECSg0D023438@repo.freebsd.org> <463B3544-BF7B-49FF-82EA-ECB5D8FBB17B@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 15 Oct 2020 at 06:59, Enji Cooper <yaneurabeya@gmail.com> wrote: > > > > On Oct 14, 2020, at 5:28 AM, Alex Richardson <arichardson@FreeBSD.org> wrote: > > > > Author: arichardson > > Date: Wed Oct 14 12:28:41 2020 > > New Revision: 366697 > > URL: https://svnweb.freebsd.org/changeset/base/366697 > > > > Log: > > 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 > > * Has this change been tested out with source filesystems other than UFS/ZFS? Not all filesystems support mmap(2). I've used ext4 and afps, but it doesn't matter since there's a fallback. > * trymmap(..) seems to be less about computing whether or not the filesystem should use mmap(2) after this change, but how it should use mmap(2). Seems like a misnamed function call now. There was always fallback code in case mmap fails: https://github.com/freebsd/freebsd/blob/8349de39d23fc152c3782ee3b9eeab3df4610944/usr.bin/xinstall/xinstall.c#L1253 and https://github.com/freebsd/freebsd/blob/8349de39d23fc152c3782ee3b9eeab3df4610944/usr.bin/xinstall/xinstall.c#L1253 so it is really "should I try to use mmap()". Alex
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2BZ_v8q7p5wnK4OH_SRBYJzocaP0eTpG3_b2Kifwb7EMnZSyqw>