Skip to content
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

storage: restore lower-bound of 1 on pebbleMVCCScanner.itersBeforeSeek #96377

Merged

Conversation

sumeerbhola
Copy link
Collaborator

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 https://github.com/cockroachlabs/support/issues/2033

Epic: none

Release note: None

@blathers-crl
Copy link

blathers-crl bot commented Feb 1, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! Sorry for all the trouble this caused over in #96361 and the corresponding support ticket.

This was supposed to be temporarily removed in b258e82 but was never restored.

It sounds like that commit was the issue, but I don't recall ever planning to revert this one part of the change. I misunderstood how this itersBeforeSeek accounting works. I assumed that even if we let itersBeforeSeek drop to 0, we would reset/increment it again after the next seek. That's not the case though — once it drops to 0, we never iterate, so we never increment the value. Instead, we stop iterating entirely.

I do think it's worthwhile keeping support for the metamorphic maxItersBeforeSeek to be 0 so that we exercise a seek-only version of pebbleMVCCScanner in tests. If you agree, then we'll need to change this PR to let decrementItersBeforeSeek keep itersBeforeSeek at 0 if maxItersBeforeSeek is also set to 0.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jbowens and @nicktrav)

Copy link
Collaborator Author

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think it's worthwhile keeping support for the metamorphic maxItersBeforeSeek to be 0 so that we exercise a seek-only version of pebbleMVCCScanner in tests. If you agree, then we'll need to change this PR to let decrementItersBeforeSeek keep itersBeforeSeek at 0 if maxItersBeforeSeek is also set to 0.

Done

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jbowens and @nicktrav)

Copy link
Member

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jbowens, @nicktrav, and @sumeerbhola)


pkg/storage/pebble_mvcc_scanner.go line 558 at r2 (raw file):

			p.itersBeforeSeek = 1
		} else if p.itersBeforeSeek < 0 {
			// INVARIANT: maxItersBeforeSeek == 0 && p.itersBeforeSeek < 0.

Should this say // INVARIANT: maxItersBeforeSeek == 0 && p.itersBeforeSeek == 0.?

Copy link
Collaborator Author

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @jbowens, @nicktrav, and @nvanbenschoten)


pkg/storage/pebble_mvcc_scanner.go line 558 at r2 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Should this say // INVARIANT: maxItersBeforeSeek == 0 && p.itersBeforeSeek == 0.?

I removed the "INVARIANT:". I was trying to state the condition that holds at this point in the code, and not an invariant that is true at all times.

Copy link
Member

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @jbowens and @nicktrav)

@sumeerbhola
Copy link
Collaborator Author

TestStoreMetrics flake is the same as in #93916

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
@sumeerbhola
Copy link
Collaborator Author

Trying again with skipping this test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants