Skip to content

[experimental, do not merge!] a faster implementation of Polonius #141326

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

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

Conversation

tage64
Copy link

@tage64 tage64 commented May 21, 2025

This is an experiment to use a more lazy approach to Polonius by only invoking the
location-sensitive analysis when needed and using NLL otherwise. This means all programs that
currently compile will still use NLL for borrow checking, and the experimental location-sensitive
analysis will only be triggered if NLL encounters an invalid access. The idea is that it should not affect
performance significantly for existing programs that compile with NLL. However, it still alters the
computation of active loans in rustc_borrowck, and I want a perf run to measure the performance
impact. I expect a slight regression but hopefully not so much.

r? lqd

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 21, 2025

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@lqd lqd marked this pull request as draft May 21, 2025 08:46
@lqd
Copy link
Member

lqd commented May 21, 2025

We don't plan on landing this as-is (no need for reviews), but want to see the overhead on NLLs.

@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 May 21, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 21, 2025
[experimental, do not merge!] a faster implementation of Polonius

This is an experiment to use a more lazy approach to Polonius by only invoking the
location-sensitive analysis when needed and using NLL otherwise. This means all programs that
currently compile will still use NLL for borrow checking, and the experimental location-sensitive
analysis will only be triggered if NLL encounters an invalid access. The idea is that it should not affect
performance significantly for existing programs that compile with NLL. However, it still alters the
computation of active loans in rustc_borrowck, and I want a perf run to measure the performance
impact. I expect a slight regression but hopefully not so much.

r? lqd
@bors
Copy link
Collaborator

bors commented May 21, 2025

⌛ Trying commit 95e1a43 with merge 77f7e0d0156c8e753ba3018f883f09a1ba0ff4a6...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 21, 2025

☀️ Try build successful - checks-actions
Build commit: 77f7e0d (77f7e0d0156c8e753ba3018f883f09a1ba0ff4a6)

@rust-timer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (77f7e0d): 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.9% [0.2%, 6.2%] 31
Regressions ❌
(secondary)
1.6% [0.1%, 4.5%] 22
Improvements ✅
(primary)
-0.2% [-0.6%, -0.1%] 9
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 9
All ❌✅ (primary) 0.7% [-0.6%, 6.2%] 40

Max RSS (memory usage)

Results (primary 71.0%, secondary 24.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)
76.5% [2.1%, 197.6%] 13
Regressions ❌
(secondary)
43.4% [0.7%, 81.6%] 10
Improvements ✅
(primary)
-1.2% [-1.2%, -1.2%] 1
Improvements ✅
(secondary)
-2.8% [-7.2%, -0.5%] 7
All ❌✅ (primary) 71.0% [-1.2%, 197.6%] 14

Cycles

Results (primary 2.2%, secondary 1.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.2% [0.9%, 4.5%] 8
Regressions ❌
(secondary)
1.5% [0.5%, 3.6%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.2% [0.9%, 4.5%] 8

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 775.275s -> 776.64s (0.18%)
Artifact size: 365.51 MiB -> 365.37 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 May 21, 2025
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
#18 exporting to docker image format
#18 sending tarball 20.3s done
#18 DONE 26.8s
##[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-19]
[CI_JOB_NAME=x86_64-gnu-llvm-19]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-19', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--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', '--set', 'gcc.download-ci-gcc=true', '--enable-new-symbol-mangling']
configure: build.build          := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-19/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
test [crashes] tests/crashes/135122.rs ... ok
test [crashes] tests/crashes/134654.rs ... ok
test [crashes] tests/crashes/135528.rs ... ok
test [crashes] tests/crashes/135617.rs ... ok
2025-05-21T14:32:05.122057Z ERROR compiletest::runtest: fatal error, panic: "crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful name, add a doc-comment to the start of the test explaining why it exists and move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description ensures that the corresponding ticket is auto-closed upon merge. If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`."
test [crashes] tests/crashes/135646.rs ... FAILED
test [crashes] tests/crashes/125323.rs ... ok
test [crashes] tests/crashes/135845.rs ... ok
test [crashes] tests/crashes/135570.rs ... ok
test [crashes] tests/crashes/135718.rs ... ok
---
failures:

---- [crashes] tests/crashes/135646.rs stdout ----

error: crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful name, add a doc-comment to the start of the test explaining why it exists and move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description ensures that the corresponding ticket is auto-closed upon merge. If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`.

thread '[crashes] tests/crashes/135646.rs' panicked at src/tools/compiletest/src/runtest/crashes.rs:17:18:
fatal error
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

6 participants