This is the mail archive of the libc-alpha@sources.redhat.com 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]

New attribute "infrequent"?


Hi,
several branch prediction papers consider classification of function calls to
discover calls to exceptional code (error handling, exit etc.) and predict them
as not happening.  While this improves the call heuristics coverage
imporatatnly, I didn't considered it very important to implement, but after
generalizing it a bit, it kept in my mind for a few months now as potentially
attractive.

We can add an attribute (probably called "infrequent") to the functions.  Such
attribute exhibits a hint, that given function is definitly outside performance
cirtical code, so gcc can:

1) optimize it for size
2) use for branch prediction purposes
3) propagate the information to other functions allways calling infrequent
4) once procedure splitting is implemented (if at all), it can move whole
   function to infrequently executed section.

I don't think the attribute is generally usefull in ordinary program, as most
of functions are "infrequent", but it may make sense for C library, that
contains also a lot of infrequent code itself (and it is dificult for compiler
to realize so) and additionally adding the flags to headers should improve
branch prediction considerably.

As the difference of code size between -Os to -O2 is over 20%, in case it is
realistic to assume that 50% of libc contains such a infreqnetly done thinks,
we can reduce it considerably. 

Does this make sense?  It would imply a lot of work on glibc side to tag all
functions...

An extension can be allowing infrequent on variables too (such as stderr) and
predicting any block containing reference to such variable as infrequently
executing.

Honza


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