This is an archive of the discontinued LLVM Phabricator instance.

scudo: Optimize getSizeLSBByClassId() by compressing the table into an integer if possible. NFCI.
ClosedPublic

Authored by pcc on Apr 22 2021, 1:20 PM.

Details

Summary

With AndroidSizeClassMap all of the LSBs are in the range 4-6 so we
only need 2 bits of information per size class. Furthermore we have
32 size classes, which conveniently lets us fit all of the information
into a 64-bit integer. Do so if possible so that we can avoid a table
lookup entirely.

Diff Detail

Event Timeline

pcc requested review of this revision.Apr 22 2021, 1:20 PM
pcc created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 1:20 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
eugenis accepted this revision.Apr 22 2021, 1:41 PM

Nice.
If this is a significant optimization, we might want to request it through the allocator config and fail if it is impossible - in case we change the size class map in the future and break this by accident.

This revision is now accepted and ready to land.Apr 22 2021, 1:41 PM
pcc added a comment.Apr 22 2021, 3:35 PM

Nice.
If this is a significant optimization, we might want to request it through the allocator config and fail if it is impossible - in case we change the size class map in the future and break this by accident.

Sure, it makes sense to have a check for the Android size class map. It seems like the most straightforward way to do it would be to expose the bool and check it via a static_assert, which I've done.