Proposition: use a hashtable instead of bsearch to locate applets

Laurent Bercot ska-dietlibc at skarnet.org
Thu May 29 16:56:04 UTC 2014


> Does this provided a noticeable performance increase? Do you have
> benchmarks?

  +1. I'm not convinced this is useful. Maybe for looping sh scripts that
prefer applets (i.e. do not perform an execve() everytime busybox is
called), but I'm willing to bet that even in that kind of script the
performance bottleneck will be something else - typically, invocation of
external commands, or any kind of system call really. For normal
scripts, the cost of application lookup is basically made negligible by
the cost of execve() in the first place. Plus dynamic symbol resolution
if you're not using static linking.

  O(log n) calls to strcmp is cheap, except in very tight loops; and a
full busybox applet invocation rarely happens in a tight loop. So I
wouldn't add to the code size to optimize that part without benchmarks
showing a real performance improvement.

-- 
  Laurent


More information about the busybox mailing list