Repository navigation
perf(resource): demangle each callee once instead of once per rule - #263
Merged
Merged
Conversation
ruleMatchesFunction demangled the callee's name on every call, so once per rule of the model, at every fixpoint iteration and every pass. It now reads the demangled name and its base from a per-thread cache keyed on the mangled name, of which both are a pure function: no synchronization is needed, and an entry stays valid after the module that held the callee is freed. The cache is cleared when it holds 65536 names, which only bounds its memory. The names a pattern is compared with, and how, are unchanged.
…haracter The two full-signature patterns of testResourceRuleMatchesFunction, "ns::Handle::open(char const*)" and "acquire_buf(void**)", both hold a '*', so they take the glob path: the exact comparison with the full demangled name was never exercised, and dropping it left the test green. "ns::Handle::close()" holds no glob character and only equals the full demangled name. It passes on the code before and after the demangling cache, and fails, in both rounds, once that comparison is dropped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ruleMatchesFunctioncompares a resource-model rule with three forms of a callee's name: the mangled name, thedemangled name, and the base name (the demangled name cut at
().of the self-analysis, profiled in Release on macOS, about half of the samples were under
ruleMatchesFunction,most of them in
__cxa_demangle.The cache is:
llvm::StringMapper thread (thread_local), since the analysis threads share nothing, so it needs no lock;held the callee is freed;
Tests
testResourceRuleMatchesFunction(11bdafe, ca191e5) pins which names a rule is compared with:Seven mutants of
ruleMatchesFunction, each dropping one way a rule may match, all make it fail.*, so they take the glob path.Verification
Setup:
-O3 -DNDEBUG, lld.mainat 703da23.Tests: the unit tests and
run_test.py(2467/2467) pass on four builds:main, this branch at 7cd302e, #241,and 7cd302e merged with #241 (the merge has no conflict).
Diagnostics: CI's self-analysis command (
run_code_analysis.py, profile fast, generic resource model, summariesin memory only), run on
main's own sources and on zlib, tinyxml2 and PCRE2.main, byte for byte, on all four.mainitself order two diagnostics differently. That is JSON and SARIF outputs list the same diagnostics in a different order from one run to the next #220; the reproduction is addedthere. Apart from that order, every run is identical.
Timing
Protocol: the self-analysis of
main's sources with CI's command (4 analyzer processes). After one warm-up passeach, the two binaries were alternated A B B A four times: 8 passes per arm. Real time is measured against an
NTP-synchronized clock.
maincome from demangling.
Related: #199. This change does not touch the sequential multi-file loop described there.