Skip to content

[EXPERIMENT] Introduce TypingMode::Codegen to avoid layout cycles #145477

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 15 commits into
base: master
Choose a base branch
from

Conversation

cjgillot
Copy link
Contributor

r? @ghost

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 16, 2025
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 16, 2025
[EXPERIMENT] Introduce `TypingMode::Codegen` to avoid layout cycles
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 16, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 16, 2025

☀️ Try build successful (CI)
Build commit: 34dd67f (34dd67f42f0f2050c773b332e2dd333618c22743, parent: cd7cbe818e4a66d46fe2df993d1b8518eba8a5cd)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (34dd67f): comparison URL.

Overall result: ❌ regressions - 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.5% [0.2%, 3.3%] 58
Regressions ❌
(secondary)
1.8% [0.0%, 19.4%] 58
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.0%] 4
All ❌✅ (primary) 0.5% [0.2%, 3.3%] 58

Max RSS (memory usage)

Results (primary 1.4%, secondary 4.3%)

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

mean range count
Regressions ❌
(primary)
1.7% [0.5%, 7.3%] 17
Regressions ❌
(secondary)
5.4% [1.2%, 12.3%] 6
Improvements ✅
(primary)
-1.3% [-1.4%, -1.3%] 2
Improvements ✅
(secondary)
-2.3% [-2.3%, -2.3%] 1
All ❌✅ (primary) 1.4% [-1.4%, 7.3%] 19

Cycles

Results (primary 2.9%, secondary 4.5%)

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

mean range count
Regressions ❌
(primary)
2.9% [2.9%, 2.9%] 1
Regressions ❌
(secondary)
5.3% [2.1%, 12.0%] 12
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-4.0%, -4.0%] 1
All ❌✅ (primary) 2.9% [2.9%, 2.9%] 1

Binary size

Results (primary 0.1%, secondary -1.0%)

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

mean range count
Regressions ❌
(primary)
0.4% [0.1%, 0.6%] 2
Regressions ❌
(secondary)
0.3% [0.1%, 0.4%] 3
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 3
Improvements ✅
(secondary)
-1.8% [-7.1%, -0.1%] 5
All ❌✅ (primary) 0.1% [-0.0%, 0.6%] 5

Bootstrap: 469.562s -> 472.464s (0.62%)
Artifact size: 377.55 MiB -> 377.67 MiB (0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 16, 2025
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 16, 2025
[EXPERIMENT] Introduce `TypingMode::Codegen` to avoid layout cycles
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 16, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 16, 2025

☀️ Try build successful (CI)
Build commit: 4e9488c (4e9488c147d4057600076145eccb670b130147d5, parent: 2e2642e641a941f0a1400c7827fd89aa86fef8f4)

@rust-timer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4e9488c): comparison URL.

Overall result: ❌ regressions - 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.4% [0.2%, 0.9%] 23
Regressions ❌
(secondary)
1.5% [0.1%, 9.7%] 59
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 2
All ❌✅ (primary) 0.4% [-1.6%, 0.9%] 24

Max RSS (memory usage)

Results (primary 1.7%, secondary 5.0%)

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

mean range count
Regressions ❌
(primary)
1.9% [0.5%, 7.5%] 19
Regressions ❌
(secondary)
6.6% [0.4%, 12.9%] 5
Improvements ✅
(primary)
-1.3% [-1.3%, -1.3%] 1
Improvements ✅
(secondary)
-2.8% [-2.8%, -2.8%] 1
All ❌✅ (primary) 1.7% [-1.3%, 7.5%] 20

Cycles

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)
4.2% [2.1%, 10.2%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-3.8%, -2.2%] 2
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%, secondary -1.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.1%, 0.1%] 1
Regressions ❌
(secondary)
0.2% [0.1%, 0.4%] 4
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 3
Improvements ✅
(secondary)
-2.9% [-6.8%, -0.0%] 3
All ❌✅ (primary) 0.0% [-0.0%, 0.1%] 4

Bootstrap: 470.222s -> 472.094s (0.40%)
Artifact size: 377.51 MiB -> 377.42 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 16, 2025
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
tests/fail/tree_borrows/reserved/int-protected-write.rs ... ok
tests/fail/weak_memory/weak_uninit.rs ... ok

FAILED TEST: tests/fail/layout_cycle.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-sr9Qqq" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/miri" "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail" "tests/fail/layout_cycle.rs" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/layout_cycle.stderr` to the actual output
--- tests/fail/layout_cycle.stderr
+++ <stderr output>
 error[E0391]: cycle detected when computing layout of `S<S<()>>`
    |
    = note: ...which requires computing layout of `<S<()> as Tr>::I`...
    = note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
+   = note: cycle used when computing layout of `S<S<()>>`
    = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
 
... 22 lines skipped ...
 
 For more information about this error, try `rustc --explain E0391`.

Full unnormalized output:
error[E0391]: cycle detected when computing layout of `S<S<()>>`
   |
   = note: ...which requires computing layout of `<S<()> as Tr>::I`...
   = note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
   = note: cycle used when computing layout of `S<S<()>>`
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: post-monomorphization error: a cycle occurred during layout computation
##[error]  --> /checkout/library/core/src/mem/mod.rs:335:5
   |
LL |     intrinsics::size_of::<T>()
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ post-monomorphization error occurred here
   |
   = note: BACKTRACE:
   = note: inside `std::mem::size_of::<S<S<()>>>` at /checkout/library/core/src/mem/mod.rs:335:5: 335:31
note: inside `foo::<S<()>>`
  --> tests/fail/layout_cycle.rs:23:5
   |
LL |     mem::size_of::<S<T>>()
   |     ^^^^^^^^^^^^^^^^^^^^^^
note: inside `main`
  --> tests/fail/layout_cycle.rs:27:20
   |
LL |     println!("{}", foo::<S<()>>());
   |                    ^^^^^^^^^^^^^^

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0391`.


full stderr:
error[E0391]: cycle detected when computing layout of `S<S<()>>`
   |
   = note: ...which requires computing layout of `<S<()> as Tr>::I`...
   = note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
   = note: cycle used when computing layout of `S<S<()>>`
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: post-monomorphization error: a cycle occurred during layout computation
##[error]  --> /checkout/library/core/src/mem/mod.rs:335:5
   |
LL |     intrinsics::size_of::<T>()
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ post-monomorphization error occurred here
   |
   = note: BACKTRACE:
   = note: inside `std::mem::size_of::<S<S<()>>>` at /checkout/library/core/src/mem/mod.rs:335:5: 335:31
note: inside `foo::<S<()>>`
  --> tests/fail/layout_cycle.rs:23:5
   |
LL |     mem::size_of::<S<T>>()
   |     ^^^^^^^^^^^^^^^^^^^^^^
note: inside `main`
  --> tests/fail/layout_cycle.rs:27:20
   |
LL |     println!("{}", foo::<S<()>>());
   |                    ^^^^^^^^^^^^^^

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 2 previous errors
---
Location:
   /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.2/src/lib.rs:365

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: <color_eyre[5de8b9825253be54]::config::EyreHook>::into_eyre_hook::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   2: eyre[ed4bc0b677c53b4b]::private::format_err<unknown>
      at <unknown source file>:<unknown line>
   3: ui_test[1209950418cedb84]::run_tests_generic::<ui_test[1209950418cedb84]::default_file_filter, ui[db642bf406b4b622]::run_tests::{closure#1}, alloc[193000162b3f6518]::boxed::Box<dyn ui_test[1209950418cedb84]::status_emitter::StatusEmitter>><unknown>
      at <unknown source file>:<unknown line>
   4: ui[db642bf406b4b622]::ui<unknown>
      at <unknown source file>:<unknown line>
   5: ui[db642bf406b4b622]::main<unknown>
      at <unknown source file>:<unknown line>
   6: std[95bf117b45f1b922]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[9ca5a6c0cec8074f]::result::Result<(), eyre[ed4bc0b677c53b4b]::Report>, core[9ca5a6c0cec8074f]::result::Result<(), eyre[ed4bc0b677c53b4b]::Report>><unknown>
      at <unknown source file>:<unknown line>
   7: std[95bf117b45f1b922]::rt::lang_start::<core[9ca5a6c0cec8074f]::result::Result<(), eyre[ed4bc0b677c53b4b]::Report>>::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   8: std[95bf117b45f1b922]::rt::lang_start_internal<unknown>
      at <unknown source file>:<unknown line>
   9: main<unknown>
      at <unknown source file>:<unknown line>
  10: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  11: _start<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/ui-de637b1a885c82e4` (exit status: 1)
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo test --target x86_64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color always --release --manifest-path /checkout/src/tools/miri/Cargo.toml -- [workdir=/checkout]` failed with exit code 1
Created at: src/bootstrap/src/core/builder/cargo.rs:423:33
Executed at: src/bootstrap/src/core/build_steps/test.rs:644:19

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:46:25
  local time: Sat Aug 16 19:11:02 UTC 2025
  network time: Sat, 16 Aug 2025 19:11:02 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

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-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants