On 02/02/2011 08:40 PM, Denys Vlasenko wrote:
> On Wednesday 02 February 2011 23:59, Rob Landley wrote:
>> On 02/02/2011 09:17 AM, Denys Vlasenko wrote:
>>> NOFORK now is an optimization,
>>> and it is used by xargs, find, and a few more applets via
>>> spawn_and_wait() function,
>>
>> Um, isn't xargs pretty much always on the right side of a pipeline?  How
>> would nofork work in that case?  (If it's not a process, how do you
>> redirect its stdin..?)
> 
> Normally xargs forks+execs a child, then waits for its death,
> then repeats this until all input words are passed as params.
> This (fork+exec)+wait is the perfect match for what nofork
> trick is about: running <applet>_main().
> 
> IOW: think about, say, a lot of deletions:
> 
> .... | xargs -n4 rm
> 
> nofork will save us from one fork syscall per four unlink syscalls.

Um, a few points:

1) It's not just unlink system calls.  You have to go through the
busybox command dispatcher again and re-parse the command line arguments
which is a nonzero amount of work (just the malloc/free traffic is going
to put us out of L1 cache and the dentries themselves probably won't
even be in L2 like my fake benchmark earlier was).

2) it's only remotely a win if the data is in disk cache and doesn't
require an actual I/O transaction, which is less likely the bigger "a
lot" is.  (Sure it's less with ssd, but remember that a _write_ to flash
can be a heck of a lot more expensive than read, what with erase blocks
and journaling/packing/wear leveling, and some of them compress too.)

3) you had to set up an example that's artifically chopping up the
action into a large number of small transactions instead of a small
number of large transactions which is pretty much "anti-optmization
101".  (Maddog gave a marvelous talk about this at LinuxWorld Expo in
2000 or so, I have it on casette tape somewhere.  Yes, really, casette
tape.  They were selling them in the lobby.)

So your example seems to me both artificial and not as big a win as it
seems.  Yeah, it probably speeds things up but if the actual question's
"Is this worth the complexity", those are important points.

But again, since you've already implemented it and aren't making
simplicity a priority, I suspect your mind's made up.  You don't have to
convince _me_ about anything...

Rob
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to