arc: improve codegen of drop - #162178
Conversation
pub fn drop_it_like_its_hot(_: Arc<()>) {}
sd a0, 0(sp)
amoadd.d.rl a0, a1, (a0)
li a1, 1
- bne a0, a1, .LBB6_2
- fence r, rw
+ beq a0, a1, .LBB6_2
+ ld ra, 8(sp)
+ addi sp, sp, 16
+ ret
+.LBB6_2:
mv a0, sp
call Arc::drop_slow
-.LBB6_2:
ld ra, 8(sp)
addi sp, sp, 16
ret |
|
Thanks for the pull request, and welcome! The Rust Project has assigned @Mark-Simulacrum (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
|
@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.
arc: improve codegen of drop
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (7aa9fe8): comparison URL. Overall result: ❌✅ regressions and improvements - BENCHMARK(S) FAILEDBenchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf ❗ ❗ ❗ ❗ ❗
❗ ❗ ❗ ❗ ❗ Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.3%, secondary -3.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.2%, secondary -0.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: missing data |
Is this something I have to take care of? The instruction regression makes sense, it's demonstrated in the diff snippet I showed above. |
|
No, you can ignore that, we have some intermittent trouble with git, sorry. |
| // This function was moved locally since there is only one caller, | ||
| // and makes it easier to reason about the the outlined fence. |
There was a problem hiding this comment.
Drive-by review: this code comment looks like a commit message. I don't think it holds value by itself.
|
|
I'm pretty certain this is caused by the |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Now that
cold_pathis properly implemented and stable, use it so that the hot path ofArc::dropis smaller. Also move the fence intodrop_slow, which preserves the correct behavior and moving an actual instruction on arches like riscv to the outlined path.This is an optimization in a similar spirit to
-O3, improving performance on the hot path (decrease in cycles) at the cost of increasing overall code size (higher instruction count).