-
Notifications
You must be signed in to change notification settings - Fork 20
MB-72082: add more stats around vector search #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9569415
prealloc buffers to improve data ingestion
Thejas-bhat 4368de3
add stats
Thejas-bhat e8094fd
add more training stats
Thejas-bhat 7df753a
resolve merge conflicts
Thejas-bhat ab373f0
fix panics
Thejas-bhat fd862a1
code cleanup
Thejas-bhat ba2a1d6
move stats definition to scorch_segment_api
Thejas-bhat d5a0202
cleanup
Thejas-bhat 1a762e5
review comments
Thejas-bhat 35ccaf5
go.mod update
Thejas-bhat a9bcac1
missing nil check
Thejas-bhat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import ( | |
| "math" | ||
| "os" | ||
| "sort" | ||
| "sync/atomic" | ||
|
|
||
| "github.com/RoaringBitmap/roaring/v2" | ||
| index "github.com/blevesearch/bleve_index_api" | ||
|
|
@@ -62,11 +63,36 @@ func (*ZapPlugin) merge(segments []seg.Segment, drops []*roaring.Bitmap, path st | |
| panic(fmt.Sprintf("oops, unexpected segment type: %T", segment)) | ||
| } | ||
| } | ||
| return mergeSegmentBases(segmentBases, drops, path, DefaultChunkMode, closeCh, s, config) | ||
|
|
||
| zapStats, ok := config[seg.StatsKey].(*seg.Stats) | ||
|
Thejas-bhat marked this conversation as resolved.
|
||
| if !ok || zapStats == nil { | ||
| zapStats = new(seg.Stats) | ||
| } | ||
|
|
||
| atomic.AddUint64(&zapStats.TotMergesBeg, 1) | ||
| atomic.AddUint64(&zapStats.TotMergeInputSegments, uint64(len(segments))) | ||
| var totalInputDocs, droppedDocs uint64 | ||
| for i, sb := range segmentBases { | ||
| totalInputDocs += sb.numDocs | ||
| if drops[i] != nil { | ||
| droppedDocs += drops[i].GetCardinality() | ||
| } | ||
| } | ||
| atomic.AddUint64(&zapStats.TotMergeDroppedDocs, droppedDocs) | ||
| atomic.AddUint64(&zapStats.TotMergeOutputDocs, totalInputDocs-droppedDocs) | ||
|
Comment on lines
+81
to
+82
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are incremented before the merge runs, so aborted/failed merges still count their docs and retries double count. TotMergeOutputDocs is also input-minus-drops, not actual output. Can we count these after success, using computeNewDocCount's result? |
||
|
|
||
| newDocNums, size, err := mergeSegmentBases(segmentBases, drops, path, DefaultChunkMode, closeCh, s, config, zapStats) | ||
| if err != nil { | ||
| atomic.AddUint64(&zapStats.TotMergesErrors, 1) | ||
| return nil, 0, err | ||
| } | ||
| atomic.AddUint64(&zapStats.TotMergesEnd, 1) | ||
| return newDocNums, size, nil | ||
| } | ||
|
|
||
| func mergeSegmentBases(segmentBases []*SegmentBase, drops []*roaring.Bitmap, path string, | ||
| chunkMode uint32, closeCh chan struct{}, s seg.StatsReporter, config map[string]interface{}) ( | ||
| chunkMode uint32, closeCh chan struct{}, s seg.StatsReporter, config map[string]interface{}, | ||
| stats *seg.Stats) ( | ||
| [][]uint64, uint64, error) { | ||
| flag := os.O_RDWR | os.O_CREATE | ||
|
|
||
|
|
@@ -92,7 +118,7 @@ func mergeSegmentBases(segmentBases []*SegmentBase, drops []*roaring.Bitmap, pat | |
| } | ||
|
|
||
| newDocNums, numDocs, storedIndexOffset, _, _, sectionsIndexOffset, err := | ||
| mergeToWriter(segmentBases, drops, chunkMode, w, closeCh, config) | ||
| mergeToWriter(segmentBases, drops, chunkMode, w, closeCh, config, stats) | ||
| if err != nil { | ||
| cleanup() | ||
| return nil, 0, err | ||
|
|
@@ -171,7 +197,8 @@ func finalizeFieldOptions(fieldOptions map[string]index.FieldIndexingOptions, | |
| } | ||
|
|
||
| func mergeToWriter(segments []*SegmentBase, drops []*roaring.Bitmap, | ||
| chunkMode uint32, w *FileWriter, closeCh chan struct{}, config map[string]interface{}) ( | ||
| chunkMode uint32, w *FileWriter, closeCh chan struct{}, config map[string]interface{}, | ||
| stats *seg.Stats) ( | ||
| newDocNums [][]uint64, numDocs, storedIndexOffset uint64, | ||
| fieldsInv []string, fieldsMap map[string]uint16, sectionsIndexOffset uint64, | ||
| err error) { | ||
|
|
@@ -205,6 +232,7 @@ func mergeToWriter(segments []*SegmentBase, drops []*roaring.Bitmap, | |
| "fieldsMap": fieldsMap, | ||
| "numDocs": numDocs, | ||
| "fieldsOptions": fieldsOptions, | ||
| "stats": stats, | ||
| } | ||
| if config != nil { | ||
| args["config"] = config | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewriteSegmentBase passes sb.stats into the merge machinery, so a persist (callback rewrite) inflates the vector-section merge counters while TotMerges* stays untouched. Should this path skip stats, or be counted as a persist?