Repository navigation
perf: deduplicate matches with a set - #4910
Merged
kddejong merged 1 commit intoNov 3, 2026
Merged
Conversation
kddejong
approved these changes
Nov 3, 2026
_dedup scanned a list of seen matches for every new match, so a template with N findings paid N^2 Match.__eq__ calls: 0.6 s for 3,000 findings. Keep a set of tuples covering every field Match.__eq__ compares instead. The key is a tuple rather than the Match because rules compare by id but are not hashable; Match.id is derived from the keyed fields. Signed-off-by: Brenden Hogan <hoganbr@amazon.com>
kddejong
force-pushed
the
perf/dedup-matches-set
branch
from
November 3, 2026 22:47
ed37953 to
40a4b9c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4910 +/- ##
=======================================
Coverage 94.80% 94.80%
=======================================
Files 441 441
Lines 16128 16129 +1
Branches 3130 3130
=======================================
+ Hits 15290 15291 +1
Misses 463 463
Partials 375 375
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Issue #, if available: none
Description of changes:
runner/template/runner.py::_dedupkept alistof matches seen so far and scanned it for every new match, so a template with N findings paid N^2Match.__eq__calls. Measured on a 2 MB template with 3,000 findings: 0.62 s in_dedupalone.The list becomes a
setof keys covering every fieldMatch.__eq__compares (message,rule.id,filename, line and column bounds,parent_id).Matchitself is not hashable through itsrule(rules compare by id but are not hashable), so the key is a tuple rather than theMatch. Output order and first-occurrence semantics are unchanged; a test pins both.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.