perf: index the seen-tracker with sibling chains and an adaptive hash spill - #1100
Open
pelletier wants to merge 1 commit into
Open
perf: index the seen-tracker with sibling chains and an adaptive hash spill#1100pelletier wants to merge 1 commit into
pelletier wants to merge 1 commit into
Conversation
… spill Key lookups scanned every entry recorded after the parent — quadratic for many-key tables (find was 33% of citm_catalog decoding). Entries now keep their named children in a sibling chain (zero hashing for small and medium tables), spilling a parent's children to a shared seeded open-addressing index past 64 children, which keeps pathological tables O(1) per lookup. Array-table refresh is O(1): instead of compacting the entry array to delete the previous element's descendants, the array table entry is replaced by a fresh entry with a fresh id, which no future lookup can reach through the old one. Arrays of scalars create no tracker entries at all. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 11, 2026
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.
Splitting #1088: this PR carries one optimization technique so its impact and review surface stay isolated.
What
The seen-tracker (duplicate-key and type-consistency validation) looked keys up by scanning every entry recorded after the parent — quadratic for many-key tables.
findwas 33% of citm_catalog decoding.[[array table]]elements previously compacted the entry array to delete the previous element's descendants (more quadratic work). The array-table entry is now replaced by a fresh entry with a fresh id; the old descendants still exist but hang off an id no future lookup can reach.Impact
Benchmarked on a dedicated linux/amd64 spot VM (t2d), go1.26.4, interleaved A/B vs the base of this PR, benchstat over 10 samples per side:
UnmarshalDataset/citm_catalog: -41.87%UnmarshalDataset/code: -9.79%Unmarshal/ReferenceFile/struct: -5.09%Unmarshal/ReferenceFile/map: -3.51%UnmarshalDataset/config: -2.48%Marshal/ReferenceFile/struct: -2.09%Marshal/SimpleDocument/struct: -1.95%RealWorldContainerdConfig: -1.57%RealWorldPyproject: +1.74%RealWorldViperRead: +2.41%Unmarshal/HugoFrontMatter: +3.08%RealWorldHugoFrontMatterBatch: +3.77%RealWorldGolangciStrict: +3.78%UnmarshalDataset/example: +4.70%Marshal/SimpleDocument/map: +5.45%UnmarshalDataset/twitter: +5.46%Unmarshal/SimpleDocument/struct: +6.75%Unmarshal/SimpleDocument/map: +8.08%Full benchstat (sec/op, allocs/op)
sec/op
allocs/op
Read in isolation: the entry struct grows (chain links + child count), which costs a few percent on tiny documents (
Unmarshal/SimpleDocument/*, twitter's many small tables) while eliminating the quadratic behavior on large ones (citm −42%, code −10%). The follow-up decode-chain PRs (native containers, fused struct decoding) win the small-document cases back several times over — see the combined numbers in the #1088 close-out.🤖 Generated with Claude Code