Skip to content

perf: avoid repeated record member scans and copies - #216

Merged
cruskell merged 1 commit into
mainfrom
codex/avoid-repeated-record-member-work
Oct 18, 2026
Merged

cruskell merged 1 commit into
mainfrom
codex/avoid-repeated-record-member-work

Conversation

@cruskell

Copy link
Copy Markdown
Owner

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.

@cruskell
cruskell merged commit 1b5dfeb into main Oct 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant