On 07/03/2018 04:49, Michael Conrad wrote:
On 3/5/2018 5:11 PM, Deweloper wrote:
Hi,
I see your point, forget about this bb_info_msg stuff.
The same result can still be achieved by using:

syslog_level = LOG_INFO
bb_error_msg(...)
syslog_level = LOG_ERR

if needed
If I interpret bloatcheck results properly, the above costs extra
45 B of code per call @x86-64.

That sounded suspicious, so I checked.  Might be worthwhile investigating what gcc was up to, because assigning a small constant to a global should be 7 bytes each on x86-64

However, pushing a small constant onto the stack should be 2 bytes, though ironically loading that small constant into a register for pass-by-register calling convention is 5.

So, with enough calls it would be worth it to create a new function, with a savings of about 9 bytes per use over the global variable trick vs. the cost of adding the new function.

(and wow, there's a nutty size optimization ... you could push a 1-byte constant onto the stack and pop it off into the register of your choice with two fewer bytes than the instruction to assign the constant directly to the register.)

-Mike

Hi,
you should take into account that the above is the worst case,
but that in reality multiple calls of bb_error_msg could be
grouped between  syslog_level assignments

syslog_level = LOG_INFO
bb_error_msg(...)
.... more calls
syslog_level = LOG_ERR

and/or that if at the end of code the second assignment
could be eventually omitted.
BTW with my proposed patch there is only one assignment
in the libbb call and the changes needed in code are
minimal, so I would be curious what the impact is in size
by changing all the bb_error_msg calls proposed by
Deweloper's patch.
Deweloper could you post your .config?

Ciao,
Tito
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to