[PATCH] D70452: [scudo][standalone] Minor optimization & improvements

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 10:24:46 PST 2019


cryptoad created this revision.
cryptoad added reviewers: hctim, morehouse, cferris, eugenis.
Herald added projects: Sanitizers, LLVM.
Herald added a subscriber: Sanitizers.
cryptoad added a comment.

And I forgot in the message the part about only checking `Size` and not `NeededSize`, adding  compiler check to make sure we do not overflow a `uptr`.
This allows us to skip a check, and doesn't impact our security.


A few small improvements and optimizations:

- when refilling the free list, push back the last batch and return the front one: this allows to keep the allocations towards the front of the region;
- instead of using 48 entries in the shuffle array, use a multiple of `MaxNumCached`;
- make the maximum number of batches to create on refil a constant; ultimately it should be configurable, but that's for later;
- `initCache` doesn't need to zero out the cache, it's already done.
- it turns out that when using `||` or `&&`, the compiler is adamant on adding a short circuit for every part of the expression. Which ends up making somewhat annoying asm with lots of test and conditional jump. I am changing that to bitwise `|` or `&` in two place so that the generated code looks better. Added comments since it might feel weird to people.

This yields to some small performance gains overall, nothing drastic
though.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70452

Files:
  compiler-rt/lib/scudo/standalone/combined.h
  compiler-rt/lib/scudo/standalone/primary32.h
  compiler-rt/lib/scudo/standalone/primary64.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70452.230102.patch
Type: text/x-patch
Size: 5161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191119/31f895c0/attachment.bin>


More information about the llvm-commits mailing list