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
cockroachdb@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 cockroachdb#96361

Also see cockroachlabs/support#2033

Epic: none

Release note: None
  • Loading branch information
sumeerbhola committed Feb 2, 2023
1 parent 90f6e40 commit a45b570
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 {
// maxItersBeforeSeek == 0 && p.itersBeforeSeek < 0.
p.itersBeforeSeek = 0
}
}
}

Expand Down

0 comments on commit a45b570

Please sign in to comment.