This is an archive of the discontinued LLVM Phabricator instance.

[scudo][standalone] Optimization pass
ClosedPublic

Authored by cryptoad on Jul 12 2019, 1:46 PM.

Details

Summary

This introduces a bunch of small optimizations with the purpose of
making the fastpath tighter:

  • tag more conditions as LIKELY/UNLIKELY: as a rule of thumb we consider that every operation related to the secondary is unlikely
  • attempt to reduce the number of potentially extraneous instructions
  • reorganize the Chunk header to not straddle a word boundary and use more appropriate types

Note that some LIKELY/UNLIKELY impact might be less obvious as
they are in slow paths (for example in secondary.cc), but at this
point I am throwing a pretty wide net, and it's consistant and doesn't
hurt.

This was mosly done for the benfit of Android, but other platforms
benefit from it too. An aarch64 Android benchmark gives:

  • before:
BM_youtube/min_time:15.000/repeats:4/manual_time_mean              445244 us       659385 us            4
BM_youtube/min_time:15.000/repeats:4/manual_time_median            445007 us       658970 us            4
BM_youtube/min_time:15.000/repeats:4/manual_time_stddev               885 us         1332 us            4
  • after:
BM_youtube/min_time:15.000/repeats:4/manual_time_mean       415697 us       621925 us            4
BM_youtube/min_time:15.000/repeats:4/manual_time_median     415913 us       622061 us            4
BM_youtube/min_time:15.000/repeats:4/manual_time_stddev        990 us         1163 us            4

Additional since -Werror=conversion is enabled on some platforms we
are built on, enable it upstream to catch things early: a few sign
conversions had slept through and needed additional casting.

Event Timeline

cryptoad created this revision.Jul 12 2019, 1:46 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 12 2019, 1:46 PM
Herald added subscribers: Restricted Project, delcypher, kristof.beyls and 3 others. · View Herald Transcript
cryptoad edited the summary of this revision. (Show Details)Jul 12 2019, 1:48 PM
cryptoad updated this revision to Diff 209903.Jul 15 2019, 10:33 AM

More optimizations:

BM_youtube/min_time:15.000/repeats:4/manual_time_mean       410274 us       615999 us            4
BM_youtube/min_time:15.000/repeats:4/manual_time_median     410246 us       616125 us            4
BM_youtube/min_time:15.000/repeats:4/manual_time_stddev        302 us          587 us            4
vitalybuka accepted this revision.Jul 22 2019, 11:37 AM

Set of smaller patches may help you to bisect in case of regressions.

This revision is now accepted and ready to land.Jul 22 2019, 11:37 AM
This revision was automatically updated to reflect the committed changes.