Conversation
|
If this is good, we should do the same in secp. |
3d99298 to
adbf102
Compare
Pull Request Test Coverage Report for Build 7749854763
💛 - Coveralls |
|
Will fix CI tomorrow, I'm hosed right now. |
|
Concept ACK, will wait until CI fix. |
|
Concept ACK We should enable the trivially_copy_pass_by_ref clippy lint which enforces this. (Or maybe this PR already does, I haven't looked because you said you'd update it soon for CI :)). |
|
I had a play with trivially_copy_pass_by_ref yesterday and all it did was tell me change millions of |
adbf102 to
60e2ad8
Compare
|
This PR has shown that we (or at least I) don't have a single command that can be run to sanity check all the code in the the whole repo that doesn't take a whole age to run. Epic PITA. |
60e2ad8 to
208c2ce
Compare
|
For types with a size less than 16 bytes or so I understand this, but for 32 byte arrays it might be a pretty big performance hit to continually copy the same 32 bytes over and over on the stack instead of an 8 byte pointer. perhaps investigating perf hits caused by this might be warranted. ie. Network enum is a strong ACK, but I’m still torn on all the private and public keys. Thoughts? |
|
@junderw IIRC someone benchmarked it and the perf hit was very small. The copies are generally optimized away after inlining etc. I was thinking that it might be somewhat weird to do things like not accept references in methods called OTOH if you iterate over slices you need to use |
|
FTR This PR does not change an of instances of |
32 bytes is just 4 words (on my machine), who cares? If there are some benchmarks that prove this is slower then sure but this feels like something that the language and the compiler should be handling and the Rust convention seems to be if its |
|
utACK 208c2ce8aae9c43ee1d685a87df9f2b8e23534e1 but I'm really struggling with whether we want to bring this in without machine tooling to keep it in sync. It'll be a mildly annoying breaking change for all our users and I'd rather only do it once. |
|
@tcharding I'm unsure if your diagnosis of Clippy is correct.
Let me know if I'm wrong; there is a long list of warnings and I didn't fix them all so it's possible I'm getting mixed up reading the churn. |
|
Thanks for looking, I'll have another play with it. |
|
Props to you @apoelstra, you were correct. I've added a bunch more patches to this PR. |
|
I've had enough of this for one day, will fix CI tomorrow. |
2d5602f to
84d5877
Compare
bitcoin/src/address/mod.rs
Outdated
There was a problem hiding this comment.
In b810f1b92accb456699167502ba923583947822e:
Can just drop the ref here rather than adding a *.
hashes/src/siphash24.rs
Outdated
There was a problem hiding this comment.
In 186e94afb452a65939b07ec0f8273338a3ec7055:
We might as well deprecate the old one. We broke the shit out of everybody by changing the signatures of all those other functions, but here we can give them a little relief since we're renaming stuff.
The siphash hash is 64 bits and is `Copy`, its conversion function should therefore be named `to_u64`.
`OutPutType` is `Copy`, pass it by value. Found with: cargo +nightly clippy -- -W clippy::trivially_copy_pass_by_ref
`OutOfRangeError` is `Copy`, pass it by value. Found with: cargo +nightly clippy -- -W clippy::trivially_copy_pass_by_ref
Configure `clippy` with `avoid-breaking-exported-api = false` and then configure each crate to warn for trvial pass by reference. Fix all the predicate warnings by passing `self` by value for types that implement `Copy`. Add a single `allow` for our error type which needs to consume the inner error.
facb03a to
8184ddf
Compare
|
Rebase only, no other changes. |
|
This PR is totally non-urgent, can be re-done at any time. |
|
On ice till next release. |
9f01871 api: Run just check-api (Tobin C. Harding) 7929b51 Pass keys by value (Tobin C. Harding) Pull request description: We should pass `Copy` types by value not by reference. Pass the key types by value. This is patch 1 from #2404 ACKs for top commit: apoelstra: ACK 9f01871 this will annoy some people but I think we should do it Tree-SHA512: 18afab537edf4ade4dc1c1e5992e50060b8935531f1e3cbe1d3b94b2fcb87aafa39947f342e0e762835bda3b4091dd35b3b74ea79f4dbb3b21660ffd21d1f82e
433fd6b api: Run just check-api (Tobin C. Harding) 8fd583b Pass hash types by value (Tobin C. Harding) Pull request description: We should pass `Copy` types by value not by reference. Pass the hash types by value. Second step in the pass-copy-types-by-value work, pulled out of #2404. ACKs for top commit: apoelstra: ACK 433fd6b Kixunil: ACK 433fd6b Tree-SHA512: 999d12f60550cacc4ae19b4cbf505b25c1eed803820f22b1a706e9f95da1b7e7b422f393f4115d579927c0c476cd504036a39b3cdc06a1d6befbcff5513f7433
dc10a49 api: Run just check-api (Tobin C. Harding) 5e8f204 Pass sigs and associated types by value (Tobin C. Harding) Pull request description: We should pass `Copy` types by value not by reference. Currently this is not done in secp, but lets do it here in bitcoin. Pass by value: - `SerializedSignature` - bitcoin sigs - secp sigs - secp `Message` This is a continuation of the work to split up #2404 into manageable PRs. ACKs for top commit: apoelstra: ACK dc10a49 Kixunil: ACK dc10a49 Tree-SHA512: 8736eba067c74edb951c92357f5b3d0fc99c4fa6dc3beea579c10b3150873b74e8ec46c2c01f18818b37fca6e77c6b6edddeb6340edde6a9d8c28a4e69164c8c
|
Hey @mpbagot do you feel like checking if we need to bring any of this back to life? By that I mean do we need to do any API changes, specifically in the stabalizing crates, to pass by value. Doing so requires digging into |
|
8184ddf needs rebase |
lol, I'd smack that bot if my arm was long enough. |
The only changes that I could find were
The Clippy lint you used here (trivially_copy_pass_by_ref) doesn't seem to trigger anymore. I tried changing various functions on Copy types and enabling the lint and Clippy refused to complain.
I'll take a look at this too. |
I"m a bit lost, I looked a bunch of these up on I think
WIN. Thanks for investigating man.
|
Is that not part of the problem here? In this PR (93194aa), you made changes to functions that took only self by ref on a |
Did you enable the "api break" config parameter for Clippy? Without it it won't lint on anything in the public API. |
|
I did not, which was an oversight. I have tested everything again now with that config parameter, and I still can't trigger the |
As discussed in #708
Copytypes should be passed by value not by reference. Audit the whole codebase for reference arguments, check if they areCopy, and if so pass by value - phew.Close #708
Done as part of #2153