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

roachpb: refine Transaction proto cloning #35762

Merged

Conversation

nvanbenschoten
Copy link
Member

@nvanbenschoten nvanbenschoten commented Mar 14, 2019

Fixes #35803.

This PR includes the final two commits from #35719.

By making Transaction.ObservedTimestamps immutable (which it almost already was), we can prohibit all interior mutability of references within Transaction, give it value semantics, and eliminate the distinction between "shallow" and "deep" object cloning. This reduces the cost of a clone to a single straightforward allocation and makes working with the object easier to think about.

cc. @tbg

@cockroach-teamcity
Copy link
Member

This change is Reviewable

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 5 of 5 files at r1, 30 of 30 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@tbg
Copy link
Member

tbg commented Mar 25, 2019

TIL of "Draft PRs". Sounds useful.

@nvanbenschoten
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 25, 2019

Build failed

@nvanbenschoten
Copy link
Member Author

Looks like a build flake. One more time.

bors r+

It turns out that it was easy enough to disallow interior mutability
entirely within a Transaction and treat all of its references as
immutable. Doing so allows us to only ever need to perform shallow
clones of Transaction objects reducing the cost of a clone to a single,
fixed-size allocation.

Release note: None
@craig
Copy link
Contributor

craig bot commented Mar 25, 2019

Build failed (retrying...)

Now that Transaction.Clone doesn't perform any deep copying, it can
serve the role it should have had of simply cloning a Transaction to
a new object on the heap. Callers who only need a value can use
Transaction's full value semantics directly and simply copy it by value.

Release note: None
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/fixTxnClone192 branch from 1678583 to c5dc833 Compare March 25, 2019 18:16
@craig
Copy link
Contributor

craig bot commented Mar 25, 2019

Canceled

@nvanbenschoten
Copy link
Member Author

Merge skew. Fixed.

bors r+

craig bot pushed a commit that referenced this pull request Mar 25, 2019
35762: roachpb: refine Transaction proto cloning r=nvanbenschoten a=nvanbenschoten

Fixes #35803.

This PR includes the final two commits from #35719.

> By making Transaction.ObservedTimestamps immutable (which it almost already was), we can prohibit all interior mutability of references within Transaction, give it value semantics, and eliminate the distinction between "shallow" and "deep" object cloning. This reduces the cost of a clone to a single straightforward allocation and makes working with the object easier to think about.

cc. @tbg 

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

craig bot commented Mar 25, 2019

Build succeeded

@craig craig bot merged commit c5dc833 into cockroachdb:master Mar 25, 2019
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/fixTxnClone192 branch March 25, 2019 23:09
nvanbenschoten added a commit to nvanbenschoten/cockroach that referenced this pull request May 17, 2019
This debugging function was removed when we fixed cockroachdb#34241 and added back
in when cockroachdb#35803 appeared because it was clear that we hadn't fully fixed
the issue. It's been about 2 months since cockroachdb#35762 merged and we haven't
seen any issues since, so this can now be removed.

I don't think we meant to keep this in for the 19.1 release. We should
backport this commit.

Release note: None
craig bot pushed a commit that referenced this pull request May 17, 2019
37559: kv: remove withMarshalingDebugging function r=nvanbenschoten a=nvanbenschoten

This debugging function was removed when we fixed #34241 and added back
in when #35803 appeared because it was clear that we hadn't fully fixed
the issue. It's been about 2 months since #35762 merged and we haven't
seen any issues since, so this can now be removed.

I don't think we meant to keep this in for the 19.1 release. We should
backport this commit.

Co-authored-by: Nathan VanBenschoten <[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