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

Simplify slice::Iter::next enough that it inlines #136771

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Feb 9, 2025

Inspired by this zulip conversation: https://rust-lang.zulipchat.com/#narrow/channel/189540-t-compiler.2Fwg-mir-opt/topic/Feedback.20on.20a.20MIR.20optimization.20idea/near/498579990

Draft for now because it needs #136735 to get the codegen tests to pass.

@rustbot
Copy link
Collaborator

rustbot commented Feb 9, 2025

r? @joboet

rustbot has assigned @joboet.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 9, 2025
@scottmcm
Copy link
Member Author

scottmcm commented Feb 9, 2025

Let's see whether it actually improves things:
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 9, 2025
@bors
Copy link
Contributor

bors commented Feb 9, 2025

⌛ Trying commit f7970b3 with merge 30df00cd8218095deb80cc6b913de02f5ae4a5b0...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 9, 2025
Simplify `slice::Iter::next` enough that it inlines

Inspired by this zulip conversation: <https://rust-lang.zulipchat.com/#narrow/channel/189540-t-compiler.2Fwg-mir-opt/topic/Feedback.20on.20a.20MIR.20optimization.20idea/near/498579990>

Draft for now because it needs rust-lang#136735 to get the codegen tests to pass.
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#21 exporting to docker image format
#21 sending tarball 27.3s done
#21 DONE 33.7s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
failures:

---- [codegen] tests/codegen/issues/issue-37945.rs stdout ----

error: verification with 'FileCheck' failed
status: exit status: 1
command: "/usr/lib/llvm-18/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/issues/issue-37945/issue-37945.ll" "/checkout/tests/codegen/issues/issue-37945.rs" "--check-prefix=CHECK" "--allow-unused-prefixes" "--dump-input-context" "100"
--- stderr -------------------------------
/checkout/tests/codegen/issues/issue-37945.rs:14:17: error: CHECK-NEXT: expected string not found in input
/checkout/tests/codegen/issues/issue-37945.rs:14:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: [[A:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null
                ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/issues/issue-37945/issue-37945.ll:8:7: note: scanning from here
      ^
      ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/issues/issue-37945/issue-37945.ll:9:3: note: possible intended match here
 %_3.not = icmp eq ptr %xs.1, %xs.0
/checkout/tests/codegen/issues/issue-37945.rs:27:17: error: CHECK-NEXT: expected string not found in input
/checkout/tests/codegen/issues/issue-37945.rs:27:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: [[C:%.*]] = icmp ne ptr {{%xs.0|%xs.1}}, null
                ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/issues/issue-37945/issue-37945.ll:15:7: note: scanning from here
      ^
      ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/issues/issue-37945/issue-37945.ll:16:4: note: possible intended match here
 %_12.not = icmp eq ptr %xs.1, %xs.0

Input file: /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/issues/issue-37945/issue-37945.ll
Check file: /checkout/tests/codegen/issues/issue-37945.rs


-dump-input=help explains the following input dump.
Input was:
<<<<<<
<<<<<<
           1: ; ModuleID = 'issue_37945.20c1cf91498ad042-cgu.0' 
           2: source_filename = "issue_37945.20c1cf91498ad042-cgu.0" 
           3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 
           5:  
           5:  
           6: ; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable 
           7: define noundef zeroext i1 @is_empty_1(ptr noundef readnone %xs.0, ptr noundef nonnull readnone %xs.1) unnamed_addr #0 { 
           8: start: 
next:14'0           X error: no match found
           9:  %_3.not = icmp eq ptr %xs.1, %xs.0 
next:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:14'1       ?                                  possible intended match
          10:  ret i1 %_3.not 
next:14'0     ~~~~~~~~~~~~~~~~
          11: } 
next:14'0     ~~
next:14'0     ~
next:14'0     ~
          13: ; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable 
next:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          14: define noundef zeroext i1 @is_empty_2(ptr noundef readnone %xs.0, ptr noundef nonnull readnone %xs.1) unnamed_addr #0 { 
next:14'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          15: start: 
next:27'0           X error: no match found
          16:  %_12.not = icmp eq ptr %xs.1, %xs.0 
next:27'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:27'1        ?                                  possible intended match
          17:  ret i1 %_12.not 
next:27'0     ~~~~~~~~~~~~~~~~~
          18: } 
next:27'0     ~~
next:27'0     ~
next:27'0     ~
          20: attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(none) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" } 
next:27'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:27'0     ~
next:27'0     ~
          22: !llvm.module.flags = !{!0, !1} 
next:27'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          23: !llvm.ident = !{!2} 
next:27'0     ~~~~~~~~~~~~~~~~~~~~
next:27'0     ~
next:27'0     ~
          25: !0 = !{i32 8, !"PIC Level", i32 2} 
next:27'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          26: !1 = !{i32 2, !"RtLibUseGOT", i32 1} 
next:27'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          27: !2 = !{!"rustc version 1.86.0-nightly (1e1da50a0 2025-02-09)"} 
next:27'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------------------



@bors
Copy link
Contributor

bors commented Feb 9, 2025

☀️ Try build successful - checks-actions
Build commit: 30df00c (30df00cd8218095deb80cc6b913de02f5ae4a5b0)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (30df00c): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
9.4% [9.4%, 9.4%] 1
Improvements ✅
(primary)
-0.6% [-2.2%, -0.1%] 210
Improvements ✅
(secondary)
-0.5% [-1.1%, -0.1%] 131
All ❌✅ (primary) -0.6% [-2.2%, 0.4%] 211

Max RSS (memory usage)

Results (primary -2.2%, secondary -2.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.4% [1.7%, 2.8%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.4% [-8.5%, -2.4%] 6
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) -2.2% [-8.5%, 2.8%] 9

Cycles

Results (primary -1.0%, secondary 1.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.6% [4.6%, 4.6%] 1
Improvements ✅
(primary)
-1.0% [-1.1%, -0.9%] 2
Improvements ✅
(secondary)
-1.1% [-1.1%, -1.1%] 1
All ❌✅ (primary) -1.0% [-1.1%, -0.9%] 2

Binary size

Results (primary 0.1%, secondary -0.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.5% [0.0%, 5.0%] 28
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.5%, -0.0%] 45
Improvements ✅
(secondary)
-0.1% [-1.3%, -0.0%] 48
All ❌✅ (primary) 0.1% [-0.5%, 5.0%] 73

Bootstrap: 780.488s -> 778.559s (-0.25%)
Artifact size: 329.04 MiB -> 329.26 MiB (0.06%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants