Repository navigation
Remove indirection for Expr in Body - #164047
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[PERF] Remove indirection for `Expr` in `Body`
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (78c5042): comparison URL. Overall result: no relevant changes - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (primary -2.2%, secondary 2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.84s -> 486.162s (-0.95%) |
Expr in BodyExpr in Body
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in need_type_info.rs cc @lcnr Some changes occurred in coverage instrumentation. cc @Zalathar
cc @rust-lang/clippy |
a756be0 to
319d431
Compare
|
Changes to the size of AST and/or HIR nodes. cc @nnethercote |
|
@bors r+ rollup |
Rollup merge of #164047 - JonathanBrouwer:expr-body, r=Kivooeo Remove indirection for `Expr` in `Body` While this does not seem to have the measurable perf effect that I hoped, I still think this is nice to merge since it does theoretically remove one pointer dereference anytime a body is visited. I think this has no measurable effect because the `Expr` in the `Body` is allocated right next to the `Body` itself in the arena, so this should always be in L1 cache. This also works towards making the `Body` type simpler and possibly removing it, as after rust-lang/compiler-team#1044 it won't contain the Parameters anymore. I think we won't end up removing this type though because `BodyId` is a useful concept that is inherently linked to bodies. I might also take a look if there are other places in the compiler where a similar optimization might have measurable effect. r? @Kivooeo
nnethercote
left a comment
There was a problem hiding this comment.
Dammit, I did the thing in GitHub where I hit the "Submit review" button at the top, which doesn't actually submit a review. Recreating what I wrote:
I'm wary of optimizations that don't have any measurable effects. Also, previously all Expr fields were references, but now we have one field that's not, which is an inconsistency.
| hir-stats Block 288 (NN.N%) 6 48 | ||
| hir-stats GenericBound 256 (NN.N%) 4 64 | ||
| hir-stats - Trait 256 (NN.N%) 4 | ||
| hir-stats Body 240 (NN.N%) 3 80 |
There was a problem hiding this comment.
Why does the Body number go up but the Expr number not go down?
There was a problem hiding this comment.
The amount of bodies and expressions stayed the same, and expressions stayed the same size. A body is now larger (because it directly contains an expression) so the total is larger.
This is however an artifact of how this test measures, the total size of the arena has in fact gotten smaller, because we removed a reference per body. Perhaps we should include the total arena size in the test, would be interesting
There was a problem hiding this comment.
To be clear: Why the total size got larger is that each expression in a Body is being double counted
…uwer Rollup of 3 pull requests Successful merges: - rust-lang/rust#163918 (remove redundant unsafe) - rust-lang/rust#164047 (Remove indirection for `Expr` in `Body`) - rust-lang/rust#164154 (rustc-dev-guide subtree update)
So am I, and I would not have merged this if I believed it makes the code worse.
Is there anything we're concretely losing from this? I'm happy to revert if so. I'm also happy to revert if you simply feel strongly about this :3 The PR in my intuition makes the code slightly nicer, as it removes an allocation that is not needed, but I'm happy to revert if you wish as my reason for merging this is very subjective |
|
well, in case we keep |
|
This comment explains why the counting changed. Another reason why the inconsistency is a problem. |
|
Fyi I'm at Eurorust this week I'll get to reverting this next week. Feel free to do the revert yourself if you'd like to do this quickly :) |
|
I've spend a week thinking about this and concluded that what might solve these issues is for |
While this does not seem to have the measurable perf effect that I hoped, I still think this is nice to merge since it does theoretically remove one pointer dereference anytime a body is visited. I think this has no measurable effect because the
Exprin theBodyis allocated right next to theBodyitself in the arena, so this should always be in L1 cache.This also works towards making the
Bodytype simpler and possibly removing it, as after rust-lang/compiler-team#1044 it won't contain the Parameters anymore. I think we won't end up removing this type though becauseBodyIdis a useful concept that is inherently linked to bodies.I might also take a look if there are other places in the compiler where a similar optimization might have measurable effect.
r? @Kivooeo