-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: add MVCCRangeKeyStack
for range keys
#84975
storage: add MVCCRangeKeyStack
for range keys
#84975
Conversation
Would like some feedback on the type before I flesh this out and migrate all of the existing code. The motivation is reduced memory footprint and processing cost, a more ergonomic type, and common utility methods. |
552ed50
to
e4f754f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface makes a lot of sense to me.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @aliher1911, @erikgrinaker, @itsbilal, and @nicktrav)
pkg/storage/mvcc_key.go
line 462 at r1 (raw file):
func (s MVCCRangeKeyStack) Clone() MVCCRangeKeyStack { s.Bounds = s.Bounds.Clone() s.Versions = s.Versions.Clone()
Not sure how frequently we'll be cloning the entire stack, but to conserve allocations, this method could copy all the relevant slices into a single shared byte array since they'll all have the same lifetime.
This looks similar to what I was doing in MVCCGarbageCollectRangeKeys to track range merges. So existing code there would be easy to adapt. |
e4f754f
to
f69215d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me too.
Reviewed 2 of 2 files at r1, 1 of 1 files at r2, 30 of 30 files at r3, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @aliher1911, @erikgrinaker, and @itsbilal)
39c5c81
to
2210add
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this should be good to go now.
Reviewed 1 of 32 files at r4, 11 of 30 files at r5, 5 of 6 files at r6, 8 of 8 files at r7, 6 of 6 files at r8, 1 of 1 files at r9, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @aliher1911, @itsbilal, @jbowens, and @rhu713)
pkg/storage/mvcc_key.go
line 462 at r1 (raw file):
Previously, jbowens (Jackson Owens) wrote…
Not sure how frequently we'll be cloning the entire stack, but to conserve allocations, this method could copy all the relevant slices into a single shared byte array since they'll all have the same lifetime.
Yeah, good idea. Added a TODO
for this, but should be straightforward.
That said, we can avoid most of the cloning we do if cockroachdb/pebble#1775 can guarantee that it's safe to reuse the results of RangeKeys()
as long as the range keys haven't changed. So let's do that first and then see if there's any cloning left in the hot paths -- hopefully there won't be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 32 of 32 files at r4, 30 of 30 files at r5, 6 of 6 files at r6, 8 of 8 files at r7, 6 of 6 files at r8, 1 of 1 files at r9, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @aliher1911, @itsbilal, @jbowens, and @pavelkalinnikov)
Heads up @msbutler @gh-casper, we're making some minor changes to the data structure returned by |
2210add
to
f78f8e5
Compare
This patch adds `MVCCRangeKeyStack` and `MVCCRangeKeyVersion`, a new range key representation that will be returned by `SimpleMVCCIterator`. It is more compact, for efficiency, and comes with a set of convenience methods to simplify common range key processing. Release note: None
This patch changes `SimpleMVCCIterator.RangeKeys()` to return `MVCCRangeKeyStack` instead of `[]MVCCRangeKeyValue`. Callers have not been migrated to properly make use of this -- instead, they call `AsRangeKeyValues()` and construct and use the old data structure. The MVCC range tombstones tech note is also updated to reflect this. Release note: None
Release note: None
Release note: None
Some parts require invasive changes to MVCC stats helpers. These will shortly be consolidated with other MVCC stats logic elsewhere, so the existing logic is retained for now by using `AsRangeKeyValues()`. Release note: None
Release note: None
f78f8e5
to
4f78a76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 17 of 32 files at r4, 11 of 30 files at r11, 6 of 7 files at r12, 8 of 8 files at r13, 6 of 6 files at r14, 1 of 1 files at r15, 1 of 33 files at r16, 11 of 30 files at r17, 6 of 7 files at r18, 8 of 8 files at r19, 6 of 6 files at r20, 1 of 1 files at r21, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @aliher1911, @itsbilal, @jbowens, and @pavelkalinnikov)
TFTRs! CI failures are known flake in bors r=nicktrav,jbowens |
Build succeeded: |
storage: add
MVCCRangeKeyStack
for range keysThis patch adds
MVCCRangeKeyStack
andMVCCRangeKeyVersion
, a newrange key representation that will be returned by
SimpleMVCCIterator
.It is more compact, for efficiency, and comes with a set of convenience
methods to simplify common range key processing.
Resolves #83895.
Release note: None
storage: return
MVCCRangeKeyStack
fromSimpleMVCCIterator
This patch changes
SimpleMVCCIterator.RangeKeys()
to returnMVCCRangeKeyStack
instead of[]MVCCRangeKeyValue
. Callers have notbeen migrated to properly make use of this -- instead, they call
AsRangeKeyValues()
and construct and use the old data structure.The MVCC range tombstones tech note is also updated to reflect this.
Release note: None
storage: migrate MVCC code to
MVCCRangeKeyStack
Release note: None
*: migrate higher-level code to
MVCCRangeKeyStack
Release note: None
kvserver/gc: partially migrate to
MVCCRangeKeyStack
Some parts require invasive changes to MVCC stats helpers. These will
shortly be consolidated with other MVCC stats logic elsewhere, so the
existing logic is retained for now by using
AsRangeKeyValues()
.Release note: None
storage: remove
FirstRangeKeyAbove()
andHasRangeKeyBetween()
Release note: None