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

Rework instantiation mode selection in monomorphization #128118

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Jul 23, 2024

This PR is extremely cooked because I'm just dumping ideas into it that seem good and can bootstrap the compiler without linker errors.

I don't know if all the ideas are good yet.

r? @ghost

@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. labels Jul 23, 2024
@saethlin
Copy link
Member Author

@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 Jul 23, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 23, 2024
…try>

Don't add inlinehint to big closures

In an unoptimized incremental build we want as many items as possible to be lowered as GloballyShared, but right now monomorphization makes whole classes of instances all LocalCopy without inspecting the instance's MIR or the session settings.

Right now I'm experimenting to see what kind of an impact this can have. I think there's a pretty core design flaw currently because we make monomorphization decisions about Instances, but `cross_crate_inlinable` takes a DefId.

r? `@ghost`
@bors
Copy link
Contributor

bors commented Jul 23, 2024

⌛ Trying commit c47d3f4 with merge b53ccf2...

@bors
Copy link
Contributor

bors commented Jul 24, 2024

☀️ Try build successful - checks-actions
Build commit: b53ccf2 (b53ccf21a2cbc0afcf4a3975eb97d4edbdbc3ed9)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b53ccf2): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

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 a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.0% [0.2%, 34.9%] 38
Regressions ❌
(secondary)
2.2% [0.2%, 9.9%] 25
Improvements ✅
(primary)
-0.6% [-1.5%, -0.2%] 16
Improvements ✅
(secondary)
-33.3% [-66.4%, -0.2%] 2
All ❌✅ (primary) 2.0% [-1.5%, 34.9%] 54

Max RSS (memory usage)

Results (primary -0.6%, secondary 2.8%)

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)
5.2% [4.0%, 6.5%] 3
Regressions ❌
(secondary)
2.8% [2.8%, 2.8%] 1
Improvements ✅
(primary)
-3.5% [-7.7%, -2.0%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-7.7%, 6.5%] 9

Cycles

Results (primary 5.8%, secondary -2.0%)

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)
5.8% [1.6%, 37.9%] 20
Regressions ❌
(secondary)
5.1% [2.1%, 10.0%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-34.3% [-66.6%, -2.1%] 2
All ❌✅ (primary) 5.8% [1.6%, 37.9%] 20

Binary size

Results (primary 2.3%, secondary 2.0%)

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.9% [0.0%, 7.7%] 56
Regressions ❌
(secondary)
3.0% [0.0%, 10.7%] 27
Improvements ✅
(primary)
-0.0% [-0.2%, -0.0%] 13
Improvements ✅
(secondary)
-0.2% [-0.6%, -0.0%] 11
All ❌✅ (primary) 2.3% [-0.2%, 7.7%] 69

Bootstrap: 771.348s -> 777.681s (0.82%)
Artifact size: 328.86 MiB -> 328.99 MiB (0.04%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 24, 2024
@saethlin saethlin changed the title Don't add inlinehint to big closures Rework instantiation mode selection in monomorphization Jul 26, 2024
@saethlin
Copy link
Member Author

@bors try

@bors
Copy link
Contributor

bors commented Jul 26, 2024

⌛ Trying commit 14b76c9 with merge e5cfe0b...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 26, 2024
…try>

Rework instantiation mode selection in monomorphization

This PR is _extremely_ cooked because I'm just dumping ideas into it that seem good and can bootstrap the compiler without linker errors.

I don't know if all the ideas are good yet.

r? `@ghost`
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 26, 2024

☀️ Try build successful - checks-actions
Build commit: e5cfe0b (e5cfe0b0eee8ec2cba6584d4de6cebd69307978b)

@saethlin
Copy link
Member Author

@rust-timer build e5cfe0b

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e5cfe0b): comparison URL.

Overall result: ❌✅ regressions and improvements - BENCHMARK(S) FAILED

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

❗ ❗ ❗ ❗ ❗
Warning ⚠️: The following benchmark(s) failed to build:

  • cargo-0.60.0

❗ ❗ ❗ ❗ ❗

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
12.9% [0.1%, 175.6%] 130
Regressions ❌
(secondary)
4.9% [0.2%, 78.6%] 62
Improvements ✅
(primary)
-7.4% [-28.0%, -0.5%] 15
Improvements ✅
(secondary)
-7.9% [-67.2%, -0.4%] 13
All ❌✅ (primary) 10.8% [-28.0%, 175.6%] 145

Max RSS (memory usage)

Results (primary 6.6%, secondary 6.0%)

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)
8.0% [1.4%, 28.2%] 51
Regressions ❌
(secondary)
7.6% [3.2%, 13.2%] 13
Improvements ✅
(primary)
-7.8% [-17.0%, -2.9%] 5
Improvements ✅
(secondary)
-4.5% [-5.1%, -4.0%] 2
All ❌✅ (primary) 6.6% [-17.0%, 28.2%] 56

Cycles

Results (primary 15.4%, secondary 5.9%)

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)
17.8% [0.9%, 187.8%] 99
Regressions ❌
(secondary)
10.0% [2.3%, 69.0%] 34
Improvements ✅
(primary)
-10.4% [-23.8%, -2.6%] 9
Improvements ✅
(secondary)
-14.0% [-67.4%, -2.2%] 7
All ❌✅ (primary) 15.4% [-23.8%, 187.8%] 108

Binary size

Results (primary 12.1%, secondary 3.4%)

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)
13.6% [0.1%, 80.9%] 134
Regressions ❌
(secondary)
6.7% [0.0%, 76.4%] 66
Improvements ✅
(primary)
-1.1% [-8.3%, -0.0%] 16
Improvements ✅
(secondary)
-4.0% [-11.1%, -0.0%] 29
All ❌✅ (primary) 12.1% [-8.3%, 80.9%] 150

Bootstrap: 769.319s -> 765.958s (-0.44%)
Artifact size: 328.91 MiB -> 329.40 MiB (0.15%)

@saethlin
Copy link
Member Author

@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 Jul 27, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 27, 2024
…try>

Rework instantiation mode selection in monomorphization

This PR is _extremely_ cooked because I'm just dumping ideas into it that seem good and can bootstrap the compiler without linker errors.

I don't know if all the ideas are good yet.

r? `@ghost`
@bors
Copy link
Contributor

bors commented Jul 27, 2024

⌛ Trying commit 4f0c766 with merge 422545f...

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
------
 > importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:3aacb9c90579defe09351ac5e8ee504359f8054da6326ff19038f1b7c90e3cb2aafe33685c6d9b76ee8d2ccbd187ca80c46ab5380485abdd8c0ce7d69cd8d8fd:
------
##[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-17]
---
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-17', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--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-17/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id            := 99999999
---
failures:

---- [codegen] tests/codegen/closures-without-inlinehint.rs stdout ----

error: verification with 'FileCheck' failed
status: exit status: 2
command: "/usr/lib/llvm-17/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/closures-without-inlinehint/closures-without-inlinehint.ll" "/checkout/tests/codegen/closures-without-inlinehint.rs" "--check-prefix=CHECK" "--check-prefix" "NONMSVC" "--allow-unused-prefixes" "--dump-input-context" "100"
--- stderr -------------------------------
--- stderr -------------------------------
Could not open input file '/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/closures-without-inlinehint/closures-without-inlinehint.ll': No such file or directory



failures:

@bors
Copy link
Contributor

bors commented Jul 27, 2024

☀️ Try build successful - checks-actions
Build commit: 422545f (422545f89f7bcffb5262a4211a7d98413e44161d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (422545f): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

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 a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
66.4% [0.2%, 722.4%] 168
Regressions ❌
(secondary)
37.0% [0.2%, 592.5%] 115
Improvements ✅
(primary)
-12.1% [-72.2%, -0.2%] 19
Improvements ✅
(secondary)
-13.9% [-44.9%, -0.3%] 7
All ❌✅ (primary) 58.4% [-72.2%, 722.4%] 187

Max RSS (memory usage)

Results (primary 23.1%, secondary 4.0%)

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)
27.0% [1.0%, 269.4%] 93
Regressions ❌
(secondary)
7.5% [2.1%, 18.7%] 19
Improvements ✅
(primary)
-9.7% [-28.4%, -2.2%] 11
Improvements ✅
(secondary)
-9.3% [-17.7%, -4.5%] 5
All ❌✅ (primary) 23.1% [-28.4%, 269.4%] 104

Cycles

Results (primary 82.9%, secondary 65.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)
90.5% [0.9%, 724.9%] 138
Regressions ❌
(secondary)
69.8% [1.5%, 659.3%] 70
Improvements ✅
(primary)
-21.3% [-73.7%, -1.3%] 10
Improvements ✅
(secondary)
-29.4% [-41.8%, -5.3%] 3
All ❌✅ (primary) 82.9% [-73.7%, 724.9%] 148

Binary size

Results (primary 159.5%, secondary 54.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)
170.2% [0.1%, 924.5%] 151
Regressions ❌
(secondary)
62.3% [0.0%, 367.7%] 104
Improvements ✅
(primary)
-1.5% [-8.3%, -0.0%] 10
Improvements ✅
(secondary)
-1.5% [-8.0%, -0.0%] 14
All ❌✅ (primary) 159.5% [-8.3%, 924.5%] 161

Bootstrap: 772.472s -> 768.225s (-0.55%)
Artifact size: 329.05 MiB -> 328.80 MiB (-0.08%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 27, 2024
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants