assert more in release in rustc_ast_lowering by workingjubilee · Pull Request #142267 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation21 Commits2 Checks9 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@workingjubilee

My understanding of the compiler's architecture is that in the ast_lowering crate, we are constructing the HIR as a one-time thing per crate. This is after tokenizing, parsing, resolution, expansion, possible reparsing, reresolution, reexpansion, and so on. In other words, there are many reasons that perf-focused PRs spend a lot of time touching rustc_parse, rustc_expand, rustc_ast, and then rustc_hir and "onwards", but ast_lowering is a little bit of an odd duck.

In this crate, we have a number of debug assertions. Some are clearly expensive checks that seem like they are prohibitive to run in actual optimized compiler builds, but then there are a number that are simple asserts on integer equalities, is_empty, or the like. I believe we should do some of them even in release builds, because the correctness gain is worth the performance cost: almost zero.

@workingjubilee

@workingjubilee

@workingjubilee workingjubilee added the S-experimental

Status: Ongoing experiment that does not require reviewing and won't be merged in its current state.

label

Jun 9, 2025

@rustbot rustbot added the T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

label

Jun 9, 2025

@workingjubilee

@rust-timer

This comment has been minimized.

@rust-bors

⌛ Trying commit c62171a with merge d4e2ead

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request

Jun 9, 2025

@rust-bors

…ing, r=

[EXPERIMENTAL] assert in release builds in rustc_ast_lowering

My understanding of the compiler's architecture is that in the ast_lowering crate, we are constructing the HIR as a one-time thing per crate. This is after tokenizing, parsing, resolution, expansion, possible reparsing, reresolution, reexpansion, and so on. In other words, there are many reasons that perf-focused PRs spend a lot of time touching rustc_parse, rustc_expand, rustc_ast, and then rustc_hir and "onwards", but ast_lowering is a little bit of an odd duck.

In this crate, we have a number of debug assertions. Some are clearly expensive checks that seem like they are prohibitive to run in actual optimized compiler builds, but then there are simple integer equalities. I am curious if the latter introduce a serious problem if we simply do them.

r? @ghost

@rust-bors

☀️ Try build successful (CI)
Build commit: d4e2ead (d4e2ead1d10ad3fc360e74bb08414c0476225305)

@rust-timer

This comment has been minimized.

@rust-timer

Finished benchmarking commit (d4e2ead): comparison URL.

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

Benchmarking 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 @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌ (primary) 0.2% [0.1%, 0.3%] 9
Regressions ❌ (secondary) 0.3% [0.2%, 0.4%] 10
Improvements ✅ (primary) -1.2% [-1.2%, -1.2%] 1
Improvements ✅ (secondary) - - 0
All ❌✅ (primary) 0.1% [-1.2%, 0.3%] 10

Max RSS (memory usage)

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

Cycles

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

Binary size

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

Bootstrap: 754.885s -> 754.261s (-0.08%)
Artifact size: 372.30 MiB -> 372.35 MiB (0.01%)

@workingjubilee

hm. I suspect the index functions might be hot enough I need to back their diff out.

@workingjubilee

@rust-timer

This comment has been minimized.

bors added a commit that referenced this pull request

Jun 10, 2025

@bors

…ing, r=

[EXPERIMENTAL] assert in release builds in rustc_ast_lowering

My understanding of the compiler's architecture is that in the ast_lowering crate, we are constructing the HIR as a one-time thing per crate. This is after tokenizing, parsing, resolution, expansion, possible reparsing, reresolution, reexpansion, and so on. In other words, there are many reasons that perf-focused PRs spend a lot of time touching rustc_parse, rustc_expand, rustc_ast, and then rustc_hir and "onwards", but ast_lowering is a little bit of an odd duck.

In this crate, we have a number of debug assertions. Some are clearly expensive checks that seem like they are prohibitive to run in actual optimized compiler builds, but then there are simple integer equalities. I am curious if the latter introduce a serious problem if we simply do them.

r? @ghost

@bors

@bors

☀️ Try build successful - checks-actions
Build commit: a729c24 (a729c24463fb0fe8f3af7881cfd00143616f9bfd)

@rust-timer

This comment has been minimized.

@rust-timer

Finished benchmarking commit (a729c24): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary -3.5%, secondary -1.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌ (primary) - - 0
Regressions ❌ (secondary) 8.5% [8.5%, 8.5%] 1
Improvements ✅ (primary) -3.5% [-4.0%, -3.0%] 3
Improvements ✅ (secondary) -2.5% [-3.7%, -1.1%] 18
All ❌✅ (primary) -3.5% [-4.0%, -3.0%] 3

Cycles

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

Binary size

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

Bootstrap: 754.321s -> 755.264s (0.13%)
Artifact size: 372.15 MiB -> 372.18 MiB (0.01%)

@workingjubilee workingjubilee changed the title[EXPERIMENTAL] assert in release builds in rustc_ast_lowering assert more in release in rustc_ast_lowering

Jun 11, 2025

@rustbot

r? @compiler-errors

rustbot has assigned @compiler-errors.
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

@workingjubilee

@rustbot rustbot removed the S-experimental

Status: Ongoing experiment that does not require reviewing and won't be merged in its current state.

label

Jun 11, 2025

@oli-obk

@bors

📌 Commit dd78c95 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Jun 11, 2025

@oli-obk

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Jun 12, 2025

@workingjubilee

…n-ast-lowering, r=oli-obk

assert more in release in rustc_ast_lowering

My understanding of the compiler's architecture is that in the ast_lowering crate, we are constructing the HIR as a one-time thing per crate. This is after tokenizing, parsing, resolution, expansion, possible reparsing, reresolution, reexpansion, and so on. In other words, there are many reasons that perf-focused PRs spend a lot of time touching rustc_parse, rustc_expand, rustc_ast, and then rustc_hir and "onwards", but ast_lowering is a little bit of an odd duck.

In this crate, we have a number of debug assertions. Some are clearly expensive checks that seem like they are prohibitive to run in actual optimized compiler builds, but then there are a number that are simple asserts on integer equalities, is_empty, or the like. I believe we should do some of them even in release builds, because the correctness gain is worth the performance cost: almost zero.

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Jun 12, 2025

@workingjubilee

…n-ast-lowering, r=oli-obk

assert more in release in rustc_ast_lowering

My understanding of the compiler's architecture is that in the ast_lowering crate, we are constructing the HIR as a one-time thing per crate. This is after tokenizing, parsing, resolution, expansion, possible reparsing, reresolution, reexpansion, and so on. In other words, there are many reasons that perf-focused PRs spend a lot of time touching rustc_parse, rustc_expand, rustc_ast, and then rustc_hir and "onwards", but ast_lowering is a little bit of an odd duck.

In this crate, we have a number of debug assertions. Some are clearly expensive checks that seem like they are prohibitive to run in actual optimized compiler builds, but then there are a number that are simple asserts on integer equalities, is_empty, or the like. I believe we should do some of them even in release builds, because the correctness gain is worth the performance cost: almost zero.

bors added a commit that referenced this pull request

Jun 13, 2025

@bors

Rollup of 9 pull requests

Successful merges:

Failed merges:

r? @ghost @rustbot modify labels: rollup

try-job: aarch64-apple try-job: x86_64-msvc-1 try-job: x86_64-gnu try-job: dist-i586-gnu-i586-i686-musl try-job: test-various

bors added a commit that referenced this pull request

Jun 13, 2025

@bors

Rollup of 9 pull requests

Successful merges:

Failed merges:

r? @ghost @rustbot modify labels: rollup

try-job: aarch64-apple try-job: x86_64-msvc-1 try-job: x86_64-gnu try-job: dist-i586-gnu-i586-i686-musl try-job: test-various

rust-timer added a commit that referenced this pull request

Jun 13, 2025

@rust-timer

Rollup merge of #142267 - workingjubilee:debug-assert-less-in-ast-lowering, r=oli-obk

assert more in release in rustc_ast_lowering

My understanding of the compiler's architecture is that in the ast_lowering crate, we are constructing the HIR as a one-time thing per crate. This is after tokenizing, parsing, resolution, expansion, possible reparsing, reresolution, reexpansion, and so on. In other words, there are many reasons that perf-focused PRs spend a lot of time touching rustc_parse, rustc_expand, rustc_ast, and then rustc_hir and "onwards", but ast_lowering is a little bit of an odd duck.

In this crate, we have a number of debug assertions. Some are clearly expensive checks that seem like they are prohibitive to run in actual optimized compiler builds, but then there are a number that are simple asserts on integer equalities, is_empty, or the like. I believe we should do some of them even in release builds, because the correctness gain is worth the performance cost: almost zero.

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request

Jun 14, 2025

@bors

bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request

Jun 14, 2025

@bors

github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request

Jun 16, 2025

@bors

@Kobzol

@rust-timer

This comment has been minimized.

@rust-timer

Finished benchmarking commit (bd9d8ad): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (secondary 2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌ (primary) - - 0
Regressions ❌ (secondary) 2.7% [2.7%, 2.7%] 1
Improvements ✅ (primary) - - 0
Improvements ✅ (secondary) - - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary 5.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌ (primary) - - 0
Regressions ❌ (secondary) 5.8% [5.8%, 5.8%] 1
Improvements ✅ (primary) - - 0
Improvements ✅ (secondary) - - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 755.964s -> 690.393s (-8.67%)
Artifact size: 372.26 MiB -> 372.24 MiB (-0.00%)

github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request

Jun 18, 2025

@bors

…iaskrgr

Rollup of 9 pull requests

Successful merges:

Failed merges:

r? @ghost @rustbot modify labels: rollup

try-job: aarch64-apple try-job: x86_64-msvc-1 try-job: x86_64-gnu try-job: dist-i586-gnu-i586-i686-musl try-job: test-various

antoyo pushed a commit to rust-lang/rustc_codegen_gcc that referenced this pull request

Jun 28, 2025

@bors

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.