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/engine: extract an MVCCScanOptions struct #32389

Merged
merged 1 commit into from
Nov 15, 2018

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Nov 15, 2018

The signatures of the functions in the MVCCScan family are extremely
unwieldy. Extract an MVCCScanOptions struct for the fields that have
reasonable default values.

We can immediately realize the benefits of this change by removing
MVCCReverseScan, MVCCReverseScanWithBytes, and MVCCIterateUsingIter,
as the functionality provided by those functions can be requested with
the appropriate option in the MVCCScanOptions struct.

This paves the way towards introducing additional parameters, like
minimum and maximum timestamp bounds.

Updates #28358.

Release note: None

@benesch benesch requested a review from a team as a code owner November 15, 2018 16:44
@benesch benesch requested a review from a team November 15, 2018 16:44
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@benesch
Copy link
Contributor Author

benesch commented Nov 15, 2018

There doesn't seem to be any performance to this change, mercifully:

name                                              old time/op    new time/op    delta
MVCCScan_RocksDB/rows=1/versions=1/valueSize=8-8    6.22µs ± 6%    6.07µs ± 6%   ~     (p=0.093 n=10+10)

name                                              old speed      new speed      delta
MVCCScan_RocksDB/rows=1/versions=1/valueSize=8-8  1.29MB/s ± 5%  1.32MB/s ± 5%   ~     (p=0.084 n=10+10)

name                                              old alloc/op   new alloc/op   delta
MVCCScan_RocksDB/rows=1/versions=1/valueSize=8-8      117B ± 0%      117B ± 0%   ~     (all equal)

name                                              old allocs/op  new allocs/op  delta
MVCCScan_RocksDB/rows=1/versions=1/valueSize=8-8      2.00 ± 0%      2.00 ± 0%   ~     (all equal)

Copy link
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm: I like this cleanup. A lot.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained


pkg/storage/engine/mvcc_test.go, line 1595 at r1 (raw file):

	// A scan with consistent=false should fail in a txn.
	if _, _, _, err := MVCCScan(context.Background(), engine, keyMin, keyMax, math.MaxInt64, hlc.Timestamp{WallTime: 1}, MVCCScanOptions{Inconsistent: !false, Txn: txn1}); err == nil {

!false??? (There are several places in this file to fix).

Copy link
Contributor Author

@benesch benesch 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! 1 of 0 LGTMs obtained


pkg/storage/engine/mvcc_test.go, line 1595 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

!false??? (There are several places in this file to fix).

Hah, whoops! I thought I cleaned all of those up. (I used golang.org/x/tools/cmd/eg to do this refactor automatically, and it's not smart enough to simplify booleans.)

The signatures of the functions in the MVCCScan family are extremely
unwieldy. Extract an MVCCScanOptions struct for the fields that have
reasonable default values.

We can immediately realize the benefits of this change by removing
MVCCReverseScan, MVCCReverseScanWithBytes, and MVCCIterateUsingIter,
as the functionality provided by those functions can be requested with
the appropriate option in the MVCCScanOptions struct.

This paves the way towards introducing additional parameters, like
minimum and maximum timestamp bounds.

Updates cockroachdb#28358.

Release note: None
Copy link
Contributor Author

@benesch benesch left a comment

Choose a reason for hiding this comment

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

bors r=petermattis

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/storage/engine/mvcc_test.go, line 1595 at r1 (raw file):

Previously, benesch (Nikhil Benesch) wrote…

Hah, whoops! I thought I cleaned all of those up. (I used golang.org/x/tools/cmd/eg to do this refactor automatically, and it's not smart enough to simplify booleans.)

Done.

Copy link
Collaborator

@petermattis petermattis 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)

@craig
Copy link
Contributor

craig bot commented Nov 15, 2018

Build failed

@benesch
Copy link
Contributor Author

benesch commented Nov 15, 2018

Failures look spurious.

bors r=petermattis

craig bot pushed a commit that referenced this pull request Nov 15, 2018
32389: storage/engine: extract an MVCCScanOptions struct r=petermattis a=benesch

The signatures of the functions in the MVCCScan family are extremely
unwieldy. Extract an MVCCScanOptions struct for the fields that have
reasonable default values.

We can immediately realize the benefits of this change by removing
MVCCReverseScan, MVCCReverseScanWithBytes, and MVCCIterateUsingIter,
as the functionality provided by those functions can be requested with
the appropriate option in the MVCCScanOptions struct.

This paves the way towards introducing additional parameters, like
minimum and maximum timestamp bounds.

Updates #28358.

Release note: None

Co-authored-by: Nikhil Benesch <[email protected]>
@craig
Copy link
Contributor

craig bot commented Nov 15, 2018

Build succeeded

@craig craig bot merged commit 4678a31 into cockroachdb:master Nov 15, 2018
@benesch benesch deleted the scan-options branch November 15, 2018 22:29
craig bot pushed a commit that referenced this pull request Nov 28, 2018
32395: storage/engine: wrap long lines in tests r=petermattis a=benesch

Ignore the first commit, which is landing now in #32389.

This isn't a high-priority cleanup, but it's been driving me nuts and I was in the area.

---

The tests in this package were a case study in how to wrap code for
maximum illegibility. Enforce a line limit of 100 characters, except
where exceeding the limit by a few characters makes the code
substantially more readable.

The primary tool employed is extracting calls to context.Background()
into a per-test ctx variable.

All changes in this patch are straightforward reformattings with no
behavior changes.

Release note: None

Co-authored-by: Nikhil Benesch <[email protected]>
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