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

Shrink ObligationCauseCode #64302

Merged
merged 4 commits into from
Sep 14, 2019

Conversation

nnethercote
Copy link
Contributor

These commits reduce the size of ObligationCauseCode from 56 bytes to 32 bytes on 64-bit. This reduces instruction counts on various benchmarks by up to 1%, due to less memcpying.

These are types that get memcpy'd a lot.
The reduction in `memcpy` calls greatly outweighs the cost of the extra
allocations, for a net performance win.
The reduction in `memcpy` calls outweighs the cost of the extra
allocations, for a net performance win.
@rust-highfive
Copy link
Collaborator

r? @zackmdavis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 9, 2019
@nnethercote
Copy link
Contributor Author

@bors try

@bors
Copy link
Contributor

bors commented Sep 9, 2019

⌛ Trying commit 2e3b079 with merge afbe8d9...

bors added a commit that referenced this pull request Sep 9, 2019
Shrink `ObligationCauseCode`

These commits reduce the size of `ObligationCauseCode` from 56 bytes to 32 bytes on 64-bit. This reduces instruction counts on various benchmarks by up to 1%, due to less `memcpy`ing.
@nnethercote nnethercote mentioned this pull request Sep 9, 2019
@bors
Copy link
Contributor

bors commented Sep 9, 2019

☀️ Try build successful - checks-azure
Build commit: afbe8d9

@nnethercote
Copy link
Contributor Author

@rust-timer build afbe8d9

@rust-timer
Copy link
Collaborator

Success: Queued afbe8d9 with parent 7eb65df, comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit afbe8d9, comparison URL.

@nnethercote
Copy link
Contributor Author

BTW, I tried taking things a step further, by boxing the BuiltinDerivedObligation and ImplDerivedObligation variants of ObligationCauseCode. This shrank ObligationCauseCode from 32 bytes to 24 bytes, but ended up slowing things down because the memcpy improvements were outweighed by the cost of the additional allocations.

Also, these results are good, but I might wait a bit before landing. AFAICT, this change causes LLVM to use direct code for PredicateObligation copies instead of memcpy. (The commits reduce the size of that type from 136 bytes to 112 bytes... maybe >128 bytes is the threshold for LLVM using memcpy?) And in doing so, it hides all the remaining PredicateObligation copies from my new profiling tool, which only looks at memcpy calls!

@mati865
Copy link
Contributor

mati865 commented Sep 10, 2019

Indeed 128 is the threshold for using libc instead of memcpy: https://github.com/llvm/llvm-project/blob/127240acf1001b72c0c52863ffe3dc39b7c5fd6d/llvm/lib/Target/X86/X86Subtarget.h#L437

@nnethercote
Copy link
Contributor Author

I might wait a bit before landing

@zackmdavis: I'm ready to land now, review away :)

@zackmdavis
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 14, 2019

📌 Commit 2e3b079 has been approved by zackmdavis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2019
Centril added a commit to Centril/rust that referenced this pull request Sep 14, 2019
…ode, r=zackmdavis

Shrink `ObligationCauseCode`

These commits reduce the size of `ObligationCauseCode` from 56 bytes to 32 bytes on 64-bit. This reduces instruction counts on various benchmarks by up to 1%, due to less `memcpy`ing.
Centril added a commit to Centril/rust that referenced this pull request Sep 14, 2019
…ode, r=zackmdavis

Shrink `ObligationCauseCode`

These commits reduce the size of `ObligationCauseCode` from 56 bytes to 32 bytes on 64-bit. This reduces instruction counts on various benchmarks by up to 1%, due to less `memcpy`ing.
Centril added a commit to Centril/rust that referenced this pull request Sep 14, 2019
…ode, r=zackmdavis

Shrink `ObligationCauseCode`

These commits reduce the size of `ObligationCauseCode` from 56 bytes to 32 bytes on 64-bit. This reduces instruction counts on various benchmarks by up to 1%, due to less `memcpy`ing.
bors added a commit that referenced this pull request Sep 14, 2019
Rollup of 17 pull requests

Successful merges:

 - #63846 (Added table containing the system calls used by Instant and SystemTime.)
 - #64116 (Fix minor typo in docs.)
 - #64203 (A few cosmetic improvements to code & comments in liballoc and libcore)
 - #64302 (Shrink `ObligationCauseCode`)
 - #64372 (use randSecure and randABytes)
 - #64374 (Box `DiagnosticBuilder`.)
 - #64375 (Fast path for vec.clear/truncate )
 - #64378 (Fix inconsistent link formatting.)
 - #64384 (Trim rustc-workspace-hack)
 - #64393 ( declare EnvKey before use to fix build error)
 - #64420 (Inline `mark_neighbours_as_waiting_from`.)
 - #64422 (Remove raw string literal quotes from error index descriptions)
 - #64423 (Add self to .mailmap)
 - #64425 (typo fix)
 - #64431 (fn ptr is structural match)
 - #64435 (codegen: use "_N" (like for other locals) instead of "argN", for argument names.)
 - #64439 (fix #64430, confusing `owned_box` error message in no_std build)

Failed merges:

r? @ghost
@bors bors merged commit 2e3b079 into rust-lang:master Sep 14, 2019
@nnethercote nnethercote deleted the shrink-ObligationCauseCode branch September 14, 2019 23:27
Copy link

@m-komilov m-komilov left a comment

Choose a reason for hiding this comment

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

good job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants