Skip to content

Commit

Permalink
sstable: increment BlockBytes and BlockReadDuration together
Browse files Browse the repository at this point in the history
During a cache miss, increment the BlockBytes and BlockReadDuration iterator
stats together, immediately after the read. Previously, if an error occurred,
it was possible for the duration to be incremented without updating the bytes
stats.
  • Loading branch information
jbowens committed Jun 5, 2024
1 parent 3622ade commit 75d2a93
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions sstable/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ func (r *Reader) readBlock(
int(bh.Length+blockTrailerLen), readDuration.String())
}
if stats != nil {
stats.BlockBytes += bh.Length
stats.BlockReadDuration += readDuration
}
if err != nil {
Expand Down Expand Up @@ -628,9 +629,6 @@ func (r *Reader) readBlock(
decompressed = transformed
}

if stats != nil {
stats.BlockBytes += bh.Length
}
if decompressed.buf.Valid() {
return bufferHandle{b: decompressed.buf}, nil
}
Expand Down

0 comments on commit 75d2a93

Please # to comment.