Skip to content

Commit 0ef4b16

Browse files
committed
sstable: add separated value retrieval internal iterator stats
Add internal iterator stats for the count of separated value retrievals and the subset of them that miss the iterator's reader cache. Informs cockroachdb/cockroach#149422.
1 parent dd0f838 commit 0ef4b16

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

internal/base/iterator.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@ type InternalIteratorStats struct {
432432
// in the heap got positioned. The count here includes every sstable
433433
// iterator that got positioned in the heap.
434434
Count uint64
435+
// CountFetched is the subset of Count that were fetched.
436+
CountFetched uint64
437+
// ReaderCacheMisses is the count of separated value retrievals that did
438+
// not find the named blob file reader in the iterator's reader cache.
439+
ReaderCacheMisses uint64
435440
// ValueBytes represent the total byte length of the values (in value
436441
// blocks) of the points corresponding to Count.
437442
ValueBytes uint64
@@ -454,6 +459,8 @@ func (s *InternalIteratorStats) Merge(from InternalIteratorStats) {
454459
s.PointCount += from.PointCount
455460
s.PointsCoveredByRangeTombstones += from.PointsCoveredByRangeTombstones
456461
s.SeparatedPointValue.Count += from.SeparatedPointValue.Count
462+
s.SeparatedPointValue.CountFetched += from.SeparatedPointValue.CountFetched
463+
s.SeparatedPointValue.ReaderCacheMisses += from.SeparatedPointValue.ReaderCacheMisses
457464
s.SeparatedPointValue.ValueBytes += from.SeparatedPointValue.ValueBytes
458465
s.SeparatedPointValue.ValueBytesFetched += from.SeparatedPointValue.ValueBytesFetched
459466
}

sstable/blob/fetcher.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,13 @@ func (r *ValueFetcher) retrieve(ctx context.Context, vh Handle) (val []byte, err
164164
cr.blobFileID = vh.BlobFileID
165165
cr.diskFileNum = diskFileNum
166166
cr.rh = cr.r.InitReadHandle(&cr.preallocRH)
167+
if r.env.Stats != nil {
168+
r.env.Stats.SeparatedPointValue.ReaderCacheMisses++
169+
}
167170
}
168171

169172
if r.env.Stats != nil {
173+
r.env.Stats.SeparatedPointValue.CountFetched++
170174
r.env.Stats.SeparatedPointValue.ValueBytesFetched += uint64(vh.ValueLen)
171175
}
172176

sstable/valblk/reader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ func (f *valueBlockFetcher) getValueInternal(handle []byte, valLen uint32) (val
261261
f.valueBlockPtr = unsafe.Pointer(&f.valueBlock[0])
262262
}
263263
if f.stats != nil {
264+
f.stats.SeparatedPointValue.CountFetched++
264265
f.stats.SeparatedPointValue.ValueBytesFetched += uint64(valLen)
265266
}
266267
return f.valueBlock[vh.OffsetInBlock : vh.OffsetInBlock+vh.ValueLen], nil

0 commit comments

Comments
 (0)