[PATCH] D64664: [scudo][standalone] Optimization pass

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 13:49:35 PDT 2019


cryptoad created this revision.
cryptoad added reviewers: hctim, morehouse, eugenis, vitalybuka.
Herald added subscribers: Sanitizers, delcypher, kristof.beyls, javed.absar, mgorny, srhines.
Herald added projects: LLVM, Sanitizers.
cryptoad edited the summary of this revision.

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.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D64664

Files:
  lib/scudo/standalone/CMakeLists.txt
  lib/scudo/standalone/chunk.h
  lib/scudo/standalone/combined.h
  lib/scudo/standalone/local_cache.h
  lib/scudo/standalone/mutex.h
  lib/scudo/standalone/primary32.h
  lib/scudo/standalone/primary64.h
  lib/scudo/standalone/secondary.cc
  lib/scudo/standalone/size_class_map.h
  lib/scudo/standalone/string_utils.cc
  lib/scudo/standalone/tsd_shared.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64664.209581.patch
Type: text/x-patch
Size: 19379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190712/f6abea26/attachment.bin>


More information about the llvm-commits mailing list