This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Simplify perturb_byte logic.


On Wed, Dec 11, 2013 at 07:04:28PM -0800, Roland McGrath wrote:
> > Should be always_inline, for macros converted to function otherwise we
> > could degrade performance.
> 
> Or we could improve performance because code size actually matters more and
> the second-guessing of the compiler hasn't been helping in years (if ever)...

Yes if gcc could actually improve size by that. Size without always_inline is

-rwxr-x--- 1 ondra stu 10710437 Dec 13 09:01 libc.so 

And adding always_inline improves this to
 
-rwxr-x--- 1 ondra stu 10710167 Dec 13 09:07 libc.so 

And if compiler could accurately compute impact of inlining, not just
function size * estimated path probability.

For function in question a code is

  if (__glibc_unlikely (perturb_byte))
    memset (p, perturb_byte ^ 0xff, n);

Which is around 5 bytes (compare instruction and jump) in fast path.
Always adding call which is already 5 bytes and much more by additional
register spills on fast path is is simply bad idea (and  gcc design does
not allow estimate how many registers will get spilled.)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]