Repository navigation
fix(parser): find a repeated metadata key in linear time in the line-check recorder - #3129
Merged
Merged
Conversation
…check recorder The recorder added by #3113 kept each transaction's and posting's metadata keys in a plain list and searched it for every new key, so one entry with n keys cost n²/2 string comparisons. metadata_many_keys (50,000 keys) went from 0.11 s to 1.54 s in release and from 0.73 s to 6.7 s in debug, and fails its 15 s bound on CI runners (21 s), so main's Test job is red. KeySet keeps the list for the first 16 keys, which covers every real ledger, then moves into a hash set. The test is back to 0.12 s / 0.82 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Contributor
📊 Benchmark ResultsInstruction counts vs base (cachegrind, deterministic)
Instruction counts (cachegrind Wall clock (hyperfine)
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
What
The line-check recorder from #3113 (ADR 0010) checks each metadata key against a plain list of the earlier keys on the same transaction or posting, so one entry with n keys costs n²/2 string comparisons.
KeySetkeeps the list for the first 16 keys, which covers every real ledger, then moves into a hash set.Why
metadata_many_keys(one transaction with 50,000 keys) regressed at #3113:On CI runners it takes 21 s against its 15 s bound, so main's Test job is red, and every open PR's
buildcheck fails with it. Callgrind on main: 31 billion instructions, 59% inmemcmp.Testing
cargo test -p rustledger-parser: 1240 passed, 0 failed.test_key_set_finds_repeats_before_and_after_the_list_limit: a repeat is found both before and after the move to the hash set, andclearresets both.-D warningsclean. Only the recorder's bookkeeping changes; which items get flagged is unchanged.No CHANGELOG entry: #3113 is not released yet.
🤖 Generated with Claude Code