The strangeness called `sbin'

Pawel Jakub Dawidek pjd at FreeBSD.org
Sat Nov 12 16:47:11 UTC 2011


On Thu, Nov 10, 2011 at 09:33:21AM -0800, Peter Wemm wrote:
> On Thu, Nov 10, 2011 at 9:16 AM, Ed Schouten <ed at 80386.nl> wrote:
> > Hi Peter,
> >
> > * Peter Wemm <peter at wemm.org>, 20111110 17:56:
> >> Of course, that pales in comparison to the impact of adding
> >> /usr/local/bin to the path, but it does show this does have potential
> >> user visibility.  And there's also the issue that most most users add
> >> every possible directory to their $PATH anyway.
> >
> > Exactly. Also, there are shells nowadays that cache all binaries in PATH
> > up front, such as zsh. When they start, they loop through all dirents in
> > all directories in $PATH and add it to a big cache. This entirely
> > defeats this purpose.
> 
> I use tcsh and zsh, I'm aware of this cache.
> 
> However, libc doesn't, so things like /bin/sh when running shell
> scripts do not.  make(1) does not.  People do still care about
> buildworld time.  Simple things like changing gcc to static linking
> were a few percentage points of buildworld time, back in the day.
> Having /bin/sh as a static binary used to be 3%-5% of buildworld time,
> simply because fork/exec was faster as the copy-on-write burden was
> less.  This stuff adds up.

Peter, are you sure that one big directory is worse than many smaller
directories for lookup?

If we have many small directories the shell would do the following:

	execve("/bin/cmd")
	execve("/usr/bin/cmd")
	execve("/sbin/cmd")
	execve("/usr/sbin/cmd")

With one small directory it will do only one execve(2).

Neither ZFS nor UFS (at least with dirhash, which is the default)
doesn't implement lookup as readdir of entire directory and strcmp() in
a loop. Things are better organized and lookups are not O(n).

When you have more directories you have to pay price of multiple lookups
and multipe system calls, which for me seems much more expensive.

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20111112/879bc73d/attachment.pgp


More information about the freebsd-arch mailing list