Remove duplicated code in slice/index.rs#151726
Remove duplicated code in slice/index.rs#151726rust-bors[bot] merged 2 commits intorust-lang:mainfrom
slice/index.rs#151726Conversation
Looks like `const fn` is far enough along now that we can just not have these two copies any more, and have one call the other.
This comment has been minimized.
This comment has been minimized.
|
"Execution context was destroyed"? I'll try re-kicking CI... |
|
@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.
Remove duplicated code in `slice/index.rs`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (01347f5): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (primary -2.1%, secondary -4.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.0%, secondary 0.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 473.018s -> 471.612s (-0.30%) |
|
Weird perf result. |
|
Looking at Compiler Explorer with a simple example on |
I would expect identical code, and IIANM that is what I'm seeing. Where do you see a difference? |
@hkBst From what I'm seeing here, it looks like there are 5 |
|
@asder8215 Ah right, that is curious. But this is without optimizations, so I still expect it to make no difference when optimizations are enabled. |
|
With optimizations they come out completely identical, yup: https://godbolt.org/z/axEbj3azP (Note that I changed them to take parameters and return them, because otherwise both things optimize to NOPs.) |
bbda084 to
a3f169c
Compare
|
Hmm, I rebased and got some codegen test failures that went away with an @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.
Remove duplicated code in `slice/index.rs`
|
@scottmcm Actually, I just took a look at your godbolt link and from the looks of it, I'm not sure if it actually shows the assembly output of test_one:
xor eax, eax
mov rdx, rdi
ret
test_two:
xor eax, eax
mov rdx, rdi
retFeels like it's missing stuff like retrieving the argument from the stack pointer (because an argument And it seems like this filtering of asm output on |
Then So yes, this function really is that trivial after optimizations. If you look at the MIR https://godbolt.org/z/rdajfv9PE you'll see that even before LLVM does anything, bb0: {
StorageLive(_2);
_2 = copy (_1.0: usize);
_0 = Bound::<usize>::Included(move _2);
StorageDead(_2);
return;
}
|
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (ba32940): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -1.5%, secondary -2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.1%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 473.793s -> 473.111s (-0.14%) |
|
Good call running perf, @joboet ! With the added |
|
Oh that's really interesting @scottmcm Thanks for going into detail about the optimization! |
|
r? jhpratt @bors r+ rollup |
Rollup merge of #151726 - scottmcm:delete-duplicated-code, r=jhpratt Remove duplicated code in `slice/index.rs` Looks like `const fn` is far enough along now that we can just not have these two copies any more, and have one call the other.


Looks like
const fnis far enough along now that we can just not have these two copies any more, and have one call the other.