Skip to content

Commit

Permalink
storage: restore lower-bound of 1 on pebbleMVCCScanner.itersBeforeSeek
Browse files Browse the repository at this point in the history
This was supposed to be temporarily removed in
b258e82
but was never restored.
It accounts for a 2x slowdown in a benchmark where a scan encounters a
few keys at the beginning of the scan with > 5 versions, that cause
itersBeforeSeek to drop to 0, and then for the remaining 1000s of keys
with only 1 versions it uses SeekGE instead of Next.

Informs #96361

Also see cockroachlabs/support#2033

Epic: none

Release note: None
  • Loading branch information
sumeerbhola committed Feb 1, 2023
1 parent 90f6e40 commit d9a35df
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/storage/pebble_mvcc_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,13 @@ func (p *pebbleMVCCScanner) incrementItersBeforeSeek() {
// Decrements itersBeforeSeek while ensuring it stays positive.
func (p *pebbleMVCCScanner) decrementItersBeforeSeek() {
p.itersBeforeSeek--
if p.itersBeforeSeek < 0 {
p.itersBeforeSeek = 0
if p.itersBeforeSeek < 1 {
if maxItersBeforeSeek > 0 {
p.itersBeforeSeek = 1
} else if p.itersBeforeSeek < 0 {
// INVARIANT: maxItersBeforeSeek == 0 && p.itersBeforeSeek < 0.
p.itersBeforeSeek = 0
}
}
}

Expand Down

0 comments on commit d9a35df

Please sign in to comment.