TreeDB collections: pack semantic index deltas per batch - #1383
Open
snissn wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes TreeDB’s buffered indexed-update path so semantic index deltas for a batch are packed into one shared contiguous slice instead of allocating a separate delta backing array per changed document. It fits into the recent PR3b semantic staging/allocation work by targeting another hot allocation source in TreeDB/collections.
Changes:
- Pre-computes the total semantic index-delta count for a batch.
- Allocates one batch-local
[]indexedSemanticIndexDeltaarena and assigns each record a tight subslice into it. - Keeps the existing semantic-record contents and fallback behavior while changing only how the delta slices are backed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+9238
to
+9242
| for _, update := range updates { | ||
| if !update.indexStateChanged { | ||
| continue | ||
| } | ||
| for runtimeIdx := range runtimes { |
Comment on lines
+9249
to
+9250
| indexDeltas := make([]indexedSemanticIndexDelta, totalIndexDeltas) | ||
| indexDeltaPos := 0 |
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
[]indexedSemanticIndexDeltabacking array for every changed document.Validation
go test ./TreeDB/collections -run 'TestPR3bSemantic|TestIndexedSemantic|TestCollection.*SkipsSecondaryRoot|Test.*Rollback|Test.*AutoFlush|TestCollectionIndexedFlush' -count=1go test ./cmd/mongo_gateway_bench -run '^$' -bench '^BenchmarkDirectCollectionConcurrentUpdateBSONIndexes2CityUpdate$' -benchtime=500000x -benchmem -count=1go test ./cmd/mongo_gateway_bench -run '^$' -bench '^BenchmarkDirectCollectionConcurrentUpdateBSONIndexes2CityUpdate$' -benchtime=50000x -benchmem -count=3Benchmark evidence on the 5k docs / 500k direct indexed repeated-ID update canary, relative to #1382:
The profile still shows
appendIndexedSemanticRecordsLockedas the larger remaining semantic-record allocation source. This PR only removes the per-record delta backing arrays; it does not change publish semantics or effective coalescing behavior.