⚡[performance] Compile regular expressions in IndirectCallAnalyzer#86
Open
r0ny123 wants to merge 5 commits intodanielplohmann:masterfrom
Open
Conversation
Pre-compiling regular expressions as class attributes in IndirectCallAnalyzer significantly improves performance by avoiding repeated compilation during instruction parsing in the processBlock method. Benchmark results show a ~63% improvement in regex matching time for typical instruction patterns. Verified with new unit tests in tests/testIndirectCallAnalyzer.py. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
…nd fix linting - Pre-compiled regular expressions in IndirectCallAnalyzer for better performance. - Added unit tests in tests/testIndirectCallAnalyzer.py. - Fixed CI linting issues (unused import and formatting) in the new test file. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…nd fix CI - Pre-compiled regular expressions in IndirectCallAnalyzer for better performance. - Added unit tests in tests/testIndirectCallAnalyzer.py. - Fixed processBlock to explicitly return False if no target is resolved. - Fixed formatting in test file to satisfy CI ruff version. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
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.
This PR optimizes the
IndirectCallAnalyzerby pre-compiling regular expressions used in theprocessBlockmethod.💡 What: Moved 5 regular expression patterns from inline
re.matchcalls to class-level compiledre.Patternobjects.🎯 Why:
processBlockis a recursive method that iterates over instructions in basic blocks. Compiling regexes on every iteration is inefficient.📊 Measured Improvement: Micro-benchmarks showed a 63.6% improvement in the time taken for regex matching (from 2.23s down to 0.81s for 100k iterations of typical instruction strings).
A new test file
tests/testIndirectCallAnalyzer.pywas added to verify the regex matching and the basic dataflow logic of the analyzer.