Repository navigation
perf: fused emit for no-split add and non-rebalancing remove - #4
Merged
Merged
Conversation
When a leaf or branch does not split after an insert, emit the updated node directly instead of going through the generic chunking pipelines (add_leaf_refs / tree_*_refs_of_arrays / branch_replace_one). This mirrors the direct emission remove already uses for leaves and saves a few intermediate allocations and list traversals per add. Tree shape and node contents are unchanged.
When a removed child does not underflow, the branch keeps its shape — replace the child slot in place and emit the branch directly instead of routing through branch_replace_one's generic ref-array chunking.
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
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
Two insert/remove-path optimizations that skip the generic chunking machinery when an
addorremovedoes not need to split or rebalance. Serialized node bytes are unchanged — verified by byte-identical structure hashes across native, js_of_ocaml, and upstream cljs on the same seed data.add(d4a8ca5): when a leaf or branch has room for the new element, emit the updated node directly instead of running the full insert pipeline. In datascript-ocaml'sadd-1bench this shaved ~5% off transaction time (PSS insert is the dominant transact cost at ~2.1µs × 3 indexes).remove(b4c97e3): the symmetric fast path for branch child replacement that cannot trigger a rebalance — emit the replacement node rather than rebuilding through the generic chunking chain.Both paths fall through to the existing generic implementation whenever a split or rebalance is actually required, so behavior on overflow is unchanged.
Link to Devin session: https://app.devin.ai/sessions/a699c982a95844238c1dcd1ff6cc8d5d
Open in Devin Desktop: https://app.devin.ai/desktop/session/a699c982a95844238c1dcd1ff6cc8d5d?variant=devin
Requested by: @tiensonqin