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

compiler: Never debug_assert in codegen #127995

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

workingjubilee
Copy link
Member

@workingjubilee workingjubilee commented Jul 19, 2024

In the name of Turing and his Hoarey heralds, assert our truths before creating a monster!

The rustc_codegen_llvm and rustc_codegen_ssa crates are fairly critical for rustc's correctness. Small mistakes here can easily result in undefined behavior, since a "small mistake" can mean something like "link and execute the wrong code". We should probably run any and all asserts in these modules unconditionally on whether this is a "debug build", and damn the costs in performance.

...Especially because the costs in performance seem to be nothing. It is not clear how much correctness we gain here, but I'll take free correctness improvements.

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

compiler: Never debug_assert in codegen

In the name of Turing and his Hoarey heralds, assert our truths before creating a monster.

Currently experimenting.
@bors
Copy link
Contributor

bors commented Jul 20, 2024

⌛ Trying commit 8b49b44 with merge aa45835...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 20, 2024

☀️ Try build successful - checks-actions
Build commit: aa45835 (aa458356ed373d1b10c855d0e22e6198ea20152e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (aa45835): comparison URL.

Overall result: ✅ improvements - no 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.

@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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 3.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)
- - 0
Regressions ❌
(secondary)
3.8% [3.8%, 3.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (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)
- - 0
Regressions ❌
(secondary)
2.8% [2.8%, 2.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: 770.598s -> 769.008s (-0.21%)
Artifact size: 328.83 MiB -> 328.85 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 20, 2024
The gains in performance are not worth the costs in correctness.
This is partly because the gains are zero and the costs are unknown.
@workingjubilee workingjubilee marked this pull request as ready for review July 20, 2024 07:36
@workingjubilee
Copy link
Member Author

r? compiler

@BoxyUwU
Copy link
Member

BoxyUwU commented Jul 20, 2024

bors-r-plus

@bors rollup=never
because I figure it'd be nice for this to bisect nicely on regressions (and honestly god knows if this will fail in some weird way in actual-merge CI for some weird target lol

@bors
Copy link
Contributor

bors commented Jul 20, 2024

📌 Commit ce7b069 has been approved by BoxyUwU

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 Jul 20, 2024
@bors
Copy link
Contributor

bors commented Jul 23, 2024

⌛ Testing commit ce7b069 with merge 5ef591a...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 23, 2024
…=BoxyUwU

compiler: Never debug_assert in codegen

In the name of Turing and his Hoarey heralds, assert our truths before creating a monster!

The `rustc_codegen_llvm` and `rustc_codegen_ssa` crates are fairly critical for rustc's correctness. Small mistakes here can easily result in undefined behavior, since a "small mistake" can mean something like "link and execute the wrong code". We should probably run any and all asserts in these modules unconditionally on whether this is a "debug build", and damn the costs in performance.

...Especially because the costs in performance seem to be *nothing*. It is not clear how much correctness we gain here, but I'll take free correctness improvements.
@rust-log-analyzer
Copy link
Collaborator

The job dist-x86_64-msvc failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[2024-07-23T06:22:41Z DEBUG collector::compile::benchmark] Benchmark iteration 1/1
[2024-07-23T06:22:41Z INFO  collector::compile::execute] run_rustc with incremental=false, profile=Check, scenario=Some(Full), patch=None, backend=Llvm, phase=benchmark
[2024-07-23T06:22:41Z DEBUG collector::compile::execute] "\\\\?\\C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "rustc" "--manifest-path" "Cargo.toml" "-p" "path+file:///C:/a/_temp/msys64/tmp/.tmpkriaop#[email protected]" "--profile" "check" "--bin" "token-stream-stress-bin" "--" "--wrap-rustc-with" "Eprintln"
[2024-07-23T06:22:41Z INFO  collector::compile::execute] run_rustc with incremental=true, profile=Check, scenario=Some(IncrFull), patch=None, backend=Llvm, phase=benchmark
[2024-07-23T06:22:41Z DEBUG collector::compile::execute] "\\\\?\\C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "rustc" "--manifest-path" "Cargo.toml" "-p" "path+file:///C:/a/_temp/msys64/tmp/.tmpkriaop#[email protected]" "--profile" "check" "--bin" "token-stream-stress-bin" "--" "--wrap-rustc-with" "Eprintln" "-C" "incremental=C:\\a\\_temp\\msys64\\tmp\\.tmpkriaop\\incremental-state"
[2024-07-23T06:22:41Z INFO  collector::compile::execute] run_rustc with incremental=true, profile=Check, scenario=Some(IncrUnchanged), patch=None, backend=Llvm, phase=benchmark
[2024-07-23T06:22:41Z DEBUG collector::compile::execute] "\\\\?\\C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "rustc" "--manifest-path" "Cargo.toml" "-p" "path+file:///C:/a/_temp/msys64/tmp/.tmpkriaop#[email protected]" "--profile" "check" "--bin" "token-stream-stress-bin" "--" "--wrap-rustc-with" "Eprintln" "-C" "incremental=C:\\a\\_temp\\msys64\\tmp\\.tmpkriaop\\incremental-state"
[2024-07-23T06:22:42Z DEBUG collector::compile::benchmark] Benchmark iteration 1/1
[2024-07-23T06:22:42Z INFO  collector::compile::execute] run_rustc with incremental=false, profile=Debug, scenario=Some(Full), patch=None, backend=Llvm, phase=benchmark
[2024-07-23T06:22:42Z DEBUG collector::compile::execute] "\\\\?\\C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "rustc" "--manifest-path" "Cargo.toml" "-p" "path+file:///C:/a/_temp/msys64/tmp/.tmpjgdByu#[email protected]" "--bin" "token-stream-stress-bin" "--" "--wrap-rustc-with" "Eprintln"
[2024-07-23T06:22:42Z INFO  collector::compile::execute] run_rustc with incremental=true, profile=Debug, scenario=Some(IncrFull), patch=None, backend=Llvm, phase=benchmark
---
   Compiling rustc_driver v0.0.0 (C:\a\rust\rust\compiler\rustc_driver)
[RUSTC-TIMING] rustc_driver test:false 5.046
error: linking with `link.exe` failed: exit code: 1104
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\symbols.o" "C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1-rustc\\x86_64-pc-windows-msvc\\release\\deps\\rustc_main-cac7a0b14c781d14.rustc_main.5e3149d3b6b66fd2-cgu.0.rcgu.o" "/LIBPATH:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1-rustc\\x86_64-pc-windows-msvc\\release\\deps" "/LIBPATH:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1-rustc\\release\\deps" "/LIBPATH:C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\atlmfc\\lib\\x64" "/LIBPATH:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1-rustc\\x86_64-pc-windows-msvc\\release\\build\\stacker-789dd3deafe57b42\\out" "/LIBPATH:C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\atlmfc\\lib\\x64" "/LIBPATH:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1-rustc\\x86_64-pc-windows-msvc\\release\\build\\psm-7fda0fde8da92b20\\out" "/LIBPATH:C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\atlmfc\\lib\\x64" "/LIBPATH:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1-rustc\\x86_64-pc-windows-msvc\\release\\build\\rustc_llvm-4d68b412bbca4af1\\out" "/LIBPATH:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\llvm\\lib" "/LIBPATH:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1-rustc\\x86_64-pc-windows-msvc\\release\\deps\\rustc_driver-7d979f21ca966a9e.dll.lib" "C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\std-cef76c2685dfb4ca.dll.lib" "C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-a6954cc40265b962.rlib" "psapi.lib" "shell32.lib" "ole32.lib" "uuid.lib" "advapi32.lib" "ws2_32.lib" "advapi32.lib" "kernel32.lib" "ole32.lib" "oleaut32.lib" "bcrypt.lib" "advapi32.lib" "advapi32.lib" "cfgmgr32.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "opengl32.lib" "user32.lib" "winspool.lib" "legacy_stdio_definitions.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "kernel32.lib" "/defaultlib:libcmt" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\advapi32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-errorhandling-l1-1-3.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-file-fromapp-l1-1-0.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-handle-l1-1-0.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-ioring-l1-1-0.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-synch-l1-2-0.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-sysinfo-l1-2-0.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-sysinfo-l1-2-3.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-sysinfo-l1-2-4.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-util-l1-1-1.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-core-wow64-l1-1-1.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\api-ms-win-security-base-l1-2-2.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\avrt.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\bcp47mrm.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\bcryptprimitives.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\clfsw32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\dbghelp.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\elscore.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\fwpuclnt.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\gdi32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\icu.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\imagehlp.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\iphlpapi.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\kernel32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\ktmw32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\mswsock.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\netapi32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\normaliz.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\ntdll.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\ntdllk.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\ole32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\oleaut32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\psapi.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\rtworkq.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\txfw32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\user32.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\usp10.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\version.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\windows.networking.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\wofutil.dll_imports_indirect.lib" "C:\\a\\_temp\\msys64\\tmp\\rustc3CrDws\\ws2_32.dll_imports_indirect.lib" "/NXCOMPAT" "/LIBPATH:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage1-rustc\\x86_64-pc-windows-msvc\\release\\deps\\rustc_main-cac7a0b14c781d14.exe" "/OPT:REF,ICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/MANIFEST:EMBED" "/MANIFESTINPUT:C:\\a\\rust\\rust\\compiler\\rustc\\Windows Manifest.xml" "/WX"
  = note: LINK : fatal error LNK1104: cannot open file 'C:\a\rust\rust\build\x86_64-pc-windows-msvc\stage1-rustc\x86_64-pc-windows-msvc\release\deps\rustc_main-cac7a0b14c781d14.exe'
          

[RUSTC-TIMING] rustc_main test:false 0.601
error: could not compile `rustc-main` (bin "rustc-main") due to 1 previous error

@bors
Copy link
Contributor

bors commented Jul 23, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 23, 2024
@workingjubilee
Copy link
Member Author

I'm sorry?

@ChrisDenton
Copy link
Member

@bors retry spurious msvc error

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 23, 2024
@bors
Copy link
Contributor

bors commented Jul 25, 2024

⌛ Testing commit ce7b069 with merge 28e684b...

@bors
Copy link
Contributor

bors commented Jul 25, 2024

☀️ Test successful - checks-actions
Approved by: BoxyUwU
Pushing 28e684b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 25, 2024
@bors bors merged commit 28e684b into rust-lang:master Jul 25, 2024
7 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Jul 25, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (28e684b): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary 3.2%)

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)
3.2% [3.2%, 3.2%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.2% [3.2%, 3.2%] 1

Cycles

Results (secondary -6.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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.8% [-8.5%, -3.5%] 6
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 771.005s -> 770.337s (-0.09%)
Artifact size: 328.90 MiB -> 328.89 MiB (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants