Repository navigation
perf: avoid repeated record member scans and copies - #216
Merged
Merged
Conversation
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.
Record parsing repeatedly scanned all preceding visible member names, rebuilding anonymous-member lists; indexed aggregate initialization also cloned the entire member vector for each element. Use a declaration-local BTreeSet for O(m log m) worst-case name comparisons, borrowed anonymous-member traversal with accumulating paths, and borrowed member slices in read-only consumers. Keep the public owned-member APIs and avoid persistent caches for mutable definitions.
The reproducible frontend example measured a 2,048-field record at 87.983 -> 1.826 ms, Redis server at 91.168 -> 82.981 ms, and Git revision at 121.099 -> 116.224 ms (tokenize/parse/teardown). Separate identical-input CLI-to-IR medians for Redis server were 179.790 ms before, 171.602 ms after, and 215.171 ms with Clang 15. These are not whole-build speedups. README links the full method, source/input identities, raw CLI samples and limitations.
Validation: Rust 1.86 fmt and strict all-target/all-feature Clippy; 51 unit tests, 2,105 integration tests and 1 doc test passed (2 optional integration tests ignored). Added nested anonymous-name collision and named-member visibility regressions. Required sub-agent self-review covered core code, borrow lifetimes, benchmark example and final report, with no outstanding findings. macOS/AArch64 runtime validation is being added separately.