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: use RangeKeyChanged() in MVCCClearTimeRange #86527

Merged

Conversation

erikgrinaker
Copy link
Contributor

@erikgrinaker erikgrinaker commented Aug 21, 2022

Some minor optimizations that might yield minor performance
improvements. We don't have any benchmarks for this function, and it's
used fairly rarely.

Release justification: bug fixes and low-risk updates to new functionality

Release note: None

@erikgrinaker erikgrinaker requested review from tbg and a team August 21, 2022 15:05
@erikgrinaker erikgrinaker self-assigned this Aug 21, 2022
@erikgrinaker erikgrinaker requested review from a team as code owners August 21, 2022 15:05
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@erikgrinaker erikgrinaker force-pushed the mvcccleartimerange-rangekeychanged branch from d4bca65 to cb09df3 Compare August 21, 2022 15:09
Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 5 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @erikgrinaker)


-- commits line 70 at r4:
Also seems like low-reward, should we let this sit then?


pkg/storage/mvcc.go line 2697 at r4 (raw file):

					!clearedMeta.Timestamp.ToTimestamp().LessEq(v.Timestamp) {
					rangeKeys := iter.RangeKeysIgnoringTime()
					if rangeKeys.IsEmpty() || !rangeKeys.HasBetween(k.Timestamp, v.Timestamp.Prev()) {

This is just making the previous behavior more explicit, right? Since IsEmpty() => !HasBetween.

Copy link
Contributor Author

@erikgrinaker erikgrinaker 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 (waiting on @tbg)


-- commits line 70 at r4:

Previously, tbg (Tobias Grieger) wrote…

Also seems like low-reward, should we let this sit then?

I'd rather get everything ported to RangeKeyChanged(), so that's the canonical way to handle this. Also, this should have a decent boost when there are MVCC range tombstones present, since it avoids both a key comparison and binary search in the hot path.


pkg/storage/mvcc.go line 2697 at r4 (raw file):

Previously, tbg (Tobias Grieger) wrote…

This is just making the previous behavior more explicit, right? Since IsEmpty() => !HasBetween.

It's really a performance optimization, since HasBetween calls through to sort.Search, which was found to be really expensive over in #86515. Even though that PR now checks the empty case internally, omitting the function call entirely was found to have a non-negligible perf benefit in very hot paths like ComputeStats so may as well check it here too.

Some minor optimizations that might yield minor performance
improvements. We don't have any benchmarks for this function, and it's
used fairly rarely.

Release justification: bug fixes and low-risk updates to new functionality

Release note: None
@erikgrinaker erikgrinaker force-pushed the mvcccleartimerange-rangekeychanged branch from cb09df3 to 6a37ef3 Compare August 22, 2022 16:13
@erikgrinaker
Copy link
Contributor Author

bors r=tbg

@craig
Copy link
Contributor

craig bot commented Aug 22, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 22, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 23, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 23, 2022

Build succeeded:

@craig craig bot merged commit 80c2748 into cockroachdb:master Aug 23, 2022
@erikgrinaker erikgrinaker deleted the mvcccleartimerange-rangekeychanged branch August 23, 2022 08:44
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