Repository navigation
perf(license): remove quadratic rescans on long repetitive attribution lists - #1452
Merged
Merged
Conversation
|
mstykow
force-pushed
the
perf/license-seq-match-repetitive-lists
branch
from
October 11, 2026 17:31
e0ef2a3 to
548a1af
Compare
…n lists Files that repeat a short licence tag on every line (e.g. one "name.ogg Author / GPL V3+" per line, 300 KB-1 MB) took more than 300 s to scan. Three quadratic steps were responsible, each now linear in the work it actually has to do, with byte-identical output: - Sequence matching rescanned the whole remaining query for every single-token hit. The longest-match search now stops once nothing later can beat the best run, and visits only query positions whose token occurs in the rule range instead of every position. - merge_overlapping_matches removed merged matches with Vec::remove, shifting the tail each time; it now unlinks them in O(1). - The low-coverage wrapper filter compared every sequence match with every exact match; it now only looks at exact matches near the wrapper. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Maxim Stykow <maxim.stykow@gmail.com>
mstykow
force-pushed
the
perf/license-seq-match-repetitive-lists
branch
from
October 11, 2026 17:42
548a1af to
42f0fbf
Compare
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
name.ogg Author / GPL V3+per line, 300 KB-1 MB) took more than 300 s to scan. Three quadratic steps were responsible; each is now proportional to the work it has to do, with byte-identical output.merge_overlapping_matchesremoved merged matches withVec::remove, shifting the tail each time. It now unlinks them in O(1), preserving the existing anchor-removal behaviour.Issues
--timeoutdoes not stop it #1446 (follow-up report of 44 slow licence-like files)How to verify
slow-filesand runprovenant scan --license --compat-mode scancode --json-pp - <dir>on a build from this branch and frommain. Output matches on every truncation I compared; the full files no longer time out.--licenseonly: 28 s on main, 2.2 s here. The largest file (1.04 MB): 45 s after the first fix alone, 11.6 s now. All 44 files complete (--license --copyright,--processes 4, 117 s wall in total).Follow-up work