Uh oh!
There was an error while loading. Please reload this page.
Reduce the amount of interning and layout_of calls in const eval. - #74202
Conversation
oli-obk
commented
Jul 9, 2020
@bors try @rust-timer queue |
rust-timer
commented
Jul 9, 2020
Awaiting bors try build completion |
bors
commented
Jul 9, 2020
⌛ Trying commit 60d032b3f389e3f34d175d0e71658b5ec5e3c85f with merge 5585d82a144a6885bbd224d4aa643c0c95d39fb6... |
oli-obk
commented
Jul 9, 2020
cc @rust-lang/wg-const-eval |
bors
commented
Jul 10, 2020
☀️ Try build successful - checks-actions, checks-azure |
rust-timer
commented
Jul 10, 2020
Queued 5585d82a144a6885bbd224d4aa643c0c95d39fb6 with parent 5db778a, future comparison URL. |
rust-timer
commented
Jul 10, 2020
Finished benchmarking try commit (5585d82a144a6885bbd224d4aa643c0c95d39fb6): comparison url. |
oli-obk
commented
Jul 10, 2020
booya 5% perf improvement r? @RalfJung |
oli-obk
commented
Jul 10, 2020
@bors rollup=never |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
This looks pretty different from the old code, is all I can say here.^^ No idea if it changes behavior.
There was a problem hiding this comment.
this is not the same function. The same function invokes this function adn handles all the cases just like they are handled here.
I have not seen most of this code ever before, so I do not think I can meaningfully review this. I don't even understand how this reduces interning or Wow, we have |
oli-obk
commented
Jul 11, 2020
Interning is reduced by evaluating |
Which entry points, concretely, do you mean here? I tried to follow the code in the diff a bit but it is rather hard. There's a dozen functions on 2-3 different types that are all called the same, and when looking at a |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
This also reduces layout_of invocations, because instead of invoking that on tcx.types.usize, we just use the size in try_to_machine_usize
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
This is used in a mir optimization on every single Assert terminator:
There was a problem hiding this comment.
This is used all over the place for array lengths
There was a problem hiding this comment.
Oh so on Const we have try_eval_bits and eval but they do not call each other, and there is neither eval_bits nor try_eval. But try_eval exists on ConstKind. But it is not used to implement Const::try_eval_bits, at least not directly... I feel I need to draw a call graph by hand to understand what happens.
There was a problem hiding this comment.
Longer-term I feel like this is really the thing that ought to be called Const, and the existing Const should become ConstAndTy or so... but that is for a separate PR.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bors
commented
Jul 15, 2020
☔ The latest upstream changes (presumably #74113) made this pull request unmergeable. Please resolve the merge conflicts. |
RalfJung
commented
Jul 15, 2020
r=me after rebasing. |
oli-obk
commented
Jul 16, 2020
@bors r=RalfJung |
bors
commented
Jul 16, 2020
📌 Commit 1bf0993 has been approved by |
bors
commented
Jul 16, 2020
bors
commented
Jul 16, 2020
☀️ Test successful - checks-actions, checks-azure |
nnethercote
commented
Jul 21, 2020
The perf results from landing don't quite match the earlier results. It's still a win for @oli-obk: did anything change between the earlier run and landing that might explain these worse results? |
oli-obk
commented
Jul 21, 2020
The only thing could be some changes around inlining due to the restructuring of the modules, but I don't think this should have an effect within a single crate. If I click the red percentages to look at the details, these regressions aren't actually reflected in the detailed view (or I don't know how to read the detailed view). |
mati865
commented
Jul 21, 2020
|
oli-obk
commented
Jul 21, 2020
While there's indeed a 1.6% regression in |
oli-obk
commented
Jul 21, 2020
Ah, no I see now. Incremental loading and execution are separated. And apparently loading |
mati865
commented
Jul 21, 2020
|
r? @ghost
If we just want to get at some bits of a constant, we don't need to intern it before extracting those bits.
Also, if we want to read a
usizeorbool, we can fetch the size without invoking a query.