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: re-introduce dual buffer for iterator bounds #79993

Conversation

erikgrinaker
Copy link
Contributor

@erikgrinaker erikgrinaker commented Apr 15, 2022

For the mvcc-range-tombstones branch. Undoes a change in #79291 and #79744. Will be squashed into the original commit once merged.


storage: re-introduce dual buffer for iterator bounds

This is necessary to avoid mutating the bounds in use by
pebble.Iterator, which can interfere with seek optimizations.

Release note: None

storage: simplify pebbleIterator options comparisons

Since we now use dual buffers for bounds encoding, we can fully generate
the new pebble.IterOptions during setOptions() and compare them
directly with the existing options, which simplifies the code.

Release note: None

@erikgrinaker erikgrinaker self-assigned this Apr 15, 2022
@erikgrinaker erikgrinaker requested a review from a team as a code owner April 15, 2022 10:34
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones-iterator-buffer-reuse branch from 0c0dd89 to 06b997e Compare April 15, 2022 10:36
@erikgrinaker
Copy link
Contributor Author

erikgrinaker commented Apr 15, 2022

Performance diff when reading from a batch (reusing iterators) is negligible, and within error margins (c.f. benchmarks in #79291):

name                                        old time/op    new time/op    delta
MVCCGet_Pebble/versions=1/valueSize=8-24      2.60µs ± 4%    2.61µs ± 1%    ~     (p=0.132 n=19+19)
MVCCGet_Pebble/versions=10/valueSize=8-24     3.82µs ± 1%    3.88µs ± 1%  +1.54%  (p=0.000 n=20+19)
MVCCGet_Pebble/versions=100/valueSize=8-24    9.47µs ± 6%    9.59µs ± 3%    ~     (p=0.123 n=19+19)

Copy link
Collaborator

@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.

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


-- commits, line 5 at r2:
Can you look into why TestPebbleIterBoundSliceStabilityAndNoop did not fail?
Is it because it was removed since SetBounds is no more? We need a test that would have caught this bug.


pkg/storage/pebble_iterator.go, line 214 at r2 (raw file):

	// require either Prefix, UpperBound, or LowerBound to be set, so one of these
	// won't match the zero value of a new iterator.
	optsChanged := opts.Prefix != p.prefix ||

I didn't spot a new test for this noop optimization. If there isn't one, please add.

From past experience, this is the kind of thing that results in extremely long and painful roachtest failure investigations.

@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones branch from 6a1756c to 3bd8605 Compare April 22, 2022 13:06
@erikgrinaker erikgrinaker requested a review from a team as a code owner April 22, 2022 13:06
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 @jbowens, @nicktrav, and @sumeerbhola)


-- commits, line 5 at r2:

Previously, sumeerbhola wrote…

Can you look into why TestPebbleIterBoundSliceStabilityAndNoop did not fail?
Is it because it was removed since SetBounds is no more? We need a test that would have caught this bug.

Ah, yes, it was removed. Sloppy of me not to look closer here.


pkg/storage/pebble_iterator.go, line 214 at r2 (raw file):

Previously, sumeerbhola wrote…

I didn't spot a new test for this noop optimization. If there isn't one, please add.

From past experience, this is the kind of thing that results in extremely long and painful roachtest failure investigations.

Let's see where we land on cockroachdb/pebble#1640 first. I think it'd be beneficial to move this into Pebble, since it'd allow for more fine-grained optimization and less coupling.

@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones-iterator-buffer-reuse branch from 492183c to e72c044 Compare April 22, 2022 13:25
@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones branch from 3bd8605 to 2c06ce4 Compare May 1, 2022 10:09
@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones-iterator-buffer-reuse branch from e72c044 to a9963be Compare May 1, 2022 10:21
@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones branch from 2c06ce4 to cb77b2e Compare May 1, 2022 12:31
@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones-iterator-buffer-reuse branch from a9963be to 0226f8b Compare May 1, 2022 12:32
@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones branch from cb77b2e to 49aacac Compare May 9, 2022 08:36
@erikgrinaker erikgrinaker requested a review from a team as a May 9, 2022 08:36
@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones-iterator-buffer-reuse branch from 0226f8b to bdc0ee9 Compare May 9, 2022 08:37
@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones branch from 49aacac to e5bd560 Compare May 9, 2022 09:20
This is necessary to avoid mutating the bounds in use by
`pebble.Iterator`, which can interfere with seek optimizations.

Release note: None
Since we now use dual buffers for bounds encoding, we can fully generate
the new `pebble.IterOptions` during `setOptions()` and compare them
directly with the existing options, which simplifies the code.

Release note: None
@erikgrinaker erikgrinaker force-pushed the mvcc-range-tombstones-iterator-buffer-reuse branch from bdc0ee9 to 5214cf3 Compare May 9, 2022 09:23
@erikgrinaker
Copy link
Contributor Author

Superseded by #81242.

@erikgrinaker erikgrinaker deleted the mvcc-range-tombstones-iterator-buffer-reuse branch May 28, 2022 15:20
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