Page MenuHomePhabricator

[Clang options] Optimize optionMatches() runtime by removing mallocs
ClosedPublic

Authored by nadav on Aug 7 2020, 10:17 AM.

Details

Summary

The method optionMatches() constructs 9865 std::string instances when comparing different
options. Many of these instances exceed the size of the internal storage and force memory
allocations. This patch adds an early exit check that eliminates almost most of the string allocations
while keeping the code simple.

Example inputs:
Prefix: /, Name: Fr
Prefix: -, Name: Fr
Prefix: -, Name: fsanitize-address-field-padding=
Prefix: -, Name: fsanitize-address-globals-dead-stripping
Prefix: -, Name: fsanitize-address-poison-custom-array-cookie
Prefix: -, Name: fsanitize-address-use-after-scope
Prefix: -, Name: fsanitize-address-use-odr-indicator
Prefix: -, Name: fsanitize-blacklist=

Diff Detail

Event Timeline

nadav created this revision.Aug 7 2020, 10:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 7 2020, 10:17 AM
nadav requested review of this revision.Aug 7 2020, 10:17 AM
hoyFB accepted this revision.Aug 12 2020, 3:33 PM
hoyFB added a subscriber: hoyFB.

LGTM, thanks for the fix!

This revision is now accepted and ready to land.Aug 12 2020, 3:33 PM
This revision was landed with ongoing or failed builds.Aug 12 2020, 11:10 PM
This revision was automatically updated to reflect the committed changes.