evilsong / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

patch: speed up ClassIndex() #483

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A few months ago, I modified the code for ClassIndex() in Google's internal 
version of tcmalloc.  Making its return type unsigned can save a conversion 
from signed to unsigned, and getting rid of the ?: operators seems to help a 
little bit, because the compilers I tried (various gcc versions) weren't 
generating conditional moves for them like I'd hoped.

So, the attached patch should make tcmalloc slightly faster with no effect on 
correctness.

(BTW, if you don't have a LIKELY macro you can just replace LIKELY(x) with x.  
I tested it both ways and without LIKELY the patch is probably still 
beneficial.)

Original issue reported on code.google.com by gp...@chromium.org on 15 Nov 2012 at 12:23

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by chapp...@gmail.com on 22 Dec 2012 at 5:46

GoogleCodeExporter commented 9 years ago
r183 | chappedm@gmail.com | 2012-12-22 13:25:58 -0500 (Sat, 22 Dec 2012) | 7 
lines

issue-483: Speed up accesses to ClassIndex()

Making its return type unsigned can save a conversion from
signed to unsigned, and getting rid of the ternary operators
seems to help a little bit as well. Various gcc versions weren't
generating conditional moves for them as one would expect.

Original comment by chapp...@gmail.com on 22 Dec 2012 at 6:27