zlacker

[return to "Understanding the bin, sbin, usr/bin, usr/sbin split (2010)"]
1. EdScho+Oa[view] [source] 2022-05-11 07:57:55
>>taubek+(OP)
I once sent out a proposal on the FreeBSD lists to merge /sbin with /bin, and /usr/sbin with /usr/bin. People were concerned that this would slow down the system, due to PATH lookups taking longer. Even when I demonstrated the opposite was true (it being faster due to fewer directories needing to be scanned), I wasn't able to get consensus. What a shame.
◧◩
2. mekste+fv[view] [source] 2022-05-11 11:24:44
>>EdScho+Oa
What ancient system makes a speed difference in command lookup in PATH?
◧◩◪
3. EdScho+tz[view] [source] 2022-05-11 11:57:27
>>mekste+fv
Calls like execvp() do little more than splitting PATH on ':', followed by repeatedly invoking execve() on ${dir}/${filename}. The fewer elements you have in PATH, the fewer execve() calls need to be performed in the worst case.
◧◩◪◨
4. mekste+nA[view] [source] 2022-05-11 12:02:55
>>EdScho+tz
Sounds like they need fixed for inefficient handling of simple operation.
◧◩◪◨⬒
5. koenig+681[view] [source] 2022-05-11 14:48:28
>>mekste+nA
I’m assuming you are proposing to stat each candidate before trying to execve it. I’m also assuming that a stat system call is roughly as expensive as an execve of a nonexistent or non-executable path.

For every failed candidate, you are doing one system call, so roughly the same cost each way.

Now if you just do an execve, you’re just paying that cost. If you stat first, you pay the cost of another system call that doesn’t change the flow of your program at all (a nice way of saying you’re wasting time).

Unless stat is dramatically faster than exec on a nonexistent or non-executable path, there’s never a case where this is better.

[go to top]