On Sat, Apr 2, 2016 at 11:37 AM, Ron Yorston <[email protected]> wrote: > I've done some more testing of find_applet_by_name. The current code has > two tweakable parameters. KNOWN_APPNAME_OFFSETS is the number of known > offsets stored in the applet_nameofs array (plus one, because we don't > store the zero offset). This defaults to 8, which is too large if only a > few applets configured. This test in the code: > > if (KNOWN_APPNAME_OFFSETS > 0 && NUM_APPLETS > 2*KNOWN_APPNAME_OFFSETS) { > > reverts to a simple linear search with no stored offsets if there are > fewer than 16 applets. The hardcoded multiplier 2 is the second thing > that can be tweaked.
Yes, that is too simplistic and not optimal. I propose that we select KNOWN_APPNAME_OFFSETS with finer granularity: #if NUM_APPLETS > 128 // With 129 applets we do two linear searches, with 1..7 strcmp's in the first one // and 1..16 strcmp's in the second. With 256 apps, second search does 1..32 strcmp's. # define KNOWN_APPNAME_OFFSETS 8 #elif NUM_APPLETS > 32 # define KNOWN_APPNAME_OFFSETS 4 #else // Save code size: do not compile speedup code at all, do only one linear search. # define KNOWN_APPNAME_OFFSETS 0 #endof _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
