[BusyBox] further ash size reduction

Vladimir N. Oleynik dzo at simtreas.ru
Fri Aug 10 03:19:08 UTC 2001


Manuel,
 
> vodz,
> 
> On Thu, Aug 09, 2001 at 04:19:42PM +0400, Vladimir N. Oleynik wrote:
> > Ur. I have achieved a prize in 52 bytes! Look this magic of syntactic indexes
> > in my performance.
> > It not real patch to CVS versions, but only demonstration patch to old syntactic
> > tables
> > their initial CVS versions. I have tried to make maximum flexibly and readably.
> 
> Very good!
> 
> > I like to compete with you Manuel.
> 
> Well, you win this round.  ;-)  There isn't any way to reduce the table
> implementation to match the function approach, although I was able to
> reduce it a little by packing 2 4-bit codes of the syntax_index_table into
> a single unsigned char and then playing games with >> and &.
> 
> As far as your function goes, I was able to trim the size by 7 bytes when
> compiling just the tables and the one function as extern (to test), but to
> do it I had to pack each 4-char group in S_I_T into a single unsigned short
> and then change the return from "return S_I_T[indx][syntax];"
> to "return (S_I_T[indx] >> syntax) & 0x0f;",
> where I also redefined
> #define  BASESYNTAX  0
> #define  DQSYNTAX    4
> #define  SQSYNTAX    8
> #define  ARISYNTAX   12
> The size difference disappeared though when put back into busybox.c, so
> it would only slow things down.  Nothing else I tried improved things
> either.

You have guessed a principle of my previous version. But it as I already wrote 
lost 20 bytes by optimization on speed. Now when there is a choice, by
optimization on
size really these manipulations will be caused in function once and the prize
can turn out.

> For minimal size, your patch sure seems to be the best solution.
> 
> In your demonstration patch, you use the function only when
> ASH_OPTIMIZE_FOR_SIZE is defined.  Do you think it is worth keeping
> the table implementation at all?  I wonder how much impact the function
> call per char verses the indirect table lookup has on interpretation speed.

I think very strongly influences:

syntax_code[input_char] vs 
function_call+strchr(spec_symbols, input_char)+syntax_code[index_calculated]

last do approximately equivalent, size gain in size table

> > Where still it is so much get time... It seems soon me will fire. ;-)
> 
> Sorry?  That didn't translate.

Aaron it has true decoded. ;-)


--w
vodz





More information about the busybox mailing list