TreeDB collections: reuse semantic document IDs in direct buffered updates - #1380
Open
snissn wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces per-update allocations in TreeDB’s direct buffered UpdateBatch path by reusing the already-cloned primary document ID key when constructing indexed semantic sidecar records, instead of cloning the document ID a second time.
Changes:
- Extend
buildIndexedSemanticUpdateRecordsto optionally accept direct bufferedprimaryEntriesand reuseprimaryEntries[i].keyas the semantic recorddocumentIDwhen available. - Wire the direct buffered update plan to pass
primaryEntriesinto semantic record construction; non-direct plans passniland keep the existing clone behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
This is a small allocation follow-up stacked on #1379.
The direct buffered update path already builds a cloned primary root key for each modified document. Semantic update records were cloning the same document ID again. This reuses the direct primary entry key for the semantic sidecar when the direct plan is available, while keeping the existing clone fallback for non-direct plans.
Scope
Validation
Exact direct 5k docs / 50k indexed repeated-ID update canary:
Local result summary:
This does not solve the broader allocation gap versus main, but it removes one redundant per-update allocation in the PR3b direct buffered path.