Skip to content

Use the fn_span when emitting function calls for better debug info. #141372

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

Merged
merged 2 commits into from
May 24, 2025

Conversation

khuey
Copy link
Contributor

@khuey khuey commented May 21, 2025

This especially improves the developer experience for long chains of function calls that span multiple lines, which is common with builder patterns, chains of iterator/future combinators, etc.

try-job: armhf-gnu
try-job: test-various
try-job: x86_64-msvc-1
try-job: arm-android

r? @jieyouxu

@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 May 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 21, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@khuey
Copy link
Contributor Author

khuey commented May 21, 2025

@rustbot label A-debuginfo

@rustbot rustbot added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label May 21, 2025
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I left a test suggestion.

@jieyouxu
Copy link
Member

@bors try

@jieyouxu
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 22, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2025
Use the fn_span when emitting function calls for better debug info.

This especially improves the developer experience for long chains of function calls that span multiple lines, which is common with builder patterns, chains of iterator/future combinators, etc.

try-job: armhf-gnu
try-job: test-various
try-job: x86_64-msvc-1

r? `@jieyouxu`
@bors
Copy link
Collaborator

bors commented May 22, 2025

⌛ Trying commit 4a65590 with merge a794f94...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 22, 2025

💔 Test failed - checks-actions

@jieyouxu
Copy link
Member

@bors try

@bors
Copy link
Collaborator

bors commented May 22, 2025

⌛ Trying commit 99355ff with merge 6da616f...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2025
Use the fn_span when emitting function calls for better debug info.

This especially improves the developer experience for long chains of function calls that span multiple lines, which is common with builder patterns, chains of iterator/future combinators, etc.

try-job: armhf-gnu
try-job: test-various
try-job: x86_64-msvc-1

r? `@jieyouxu`
@jieyouxu
Copy link
Member

@bors delegate+ (r=me if try job comes back green)

@bors
Copy link
Collaborator

bors commented May 22, 2025

✌️ @khuey, you can now approve this pull request!

If @jieyouxu told you to "r=me" after making some further change, please make that change, then do @bors r=@jieyouxu

@jieyouxu
Copy link
Member

@bors rollup=iffy (debuginfo)

@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

I'll look at the regex tmrw.

@jieyouxu jieyouxu added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 22, 2025
@khuey
Copy link
Contributor Author

khuey commented May 22, 2025

Oh, doh, the line number has to be adjusted now of course.

@jieyouxu
Copy link
Member

jieyouxu commented May 22, 2025

(You should be able to run try jobs yourself on this PR, since I delegated r+)

@khuey
Copy link
Contributor Author

khuey commented May 22, 2025

@bors try

bors added a commit that referenced this pull request May 24, 2025
Use the fn_span when emitting function calls for better debug info.

This especially improves the developer experience for long chains of function calls that span multiple lines, which is common with builder patterns, chains of iterator/future combinators, etc.

try-job: armhf-gnu
try-job: test-various
try-job: x86_64-msvc-1
try-job: arm-android

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

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 24, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 24, 2025
@khuey khuey force-pushed the ir_call_dbg_loc branch from f53fadf to 9c234c0 Compare May 24, 2025 13:22
@khuey
Copy link
Contributor Author

khuey commented May 24, 2025

@bors r=@jieyouxu

@bors
Copy link
Collaborator

bors commented May 24, 2025

📌 Commit 9c234c0 has been approved by jieyouxu

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 24, 2025
@bors
Copy link
Collaborator

bors commented May 24, 2025

⌛ Testing commit 9c234c0 with merge 5e16c66...

@bors
Copy link
Collaborator

bors commented May 24, 2025

☀️ Test successful - checks-actions
Approved by: jieyouxu
Pushing 5e16c66 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 24, 2025
@bors bors merged commit 5e16c66 into rust-lang:master May 24, 2025
7 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 24, 2025
Copy link

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 038d599 (parent) -> 5e16c66 (this PR)

Test differences

Show 10 test diffs

Stage 1

  • [ui] tests/ui/panics/location-detail-unwrap-multiline.rs: [missing] -> pass (J3)
  • [debuginfo-gdb] tests/debuginfo/multiline-calls.rs: [missing] -> pass (J5)
  • [debuginfo-gdb] tests/debuginfo/multiline-calls.rs: [missing] -> ignore (ignored when the GDB version is lower than 16.0) (J7)

Stage 2

  • [debuginfo-gdb] tests/debuginfo/multiline-calls.rs: [missing] -> ignore (ignored when the GDB version is lower than 16.0) (J0)
  • [ui] tests/ui/panics/location-detail-unwrap-multiline.rs: [missing] -> ignore (ignored when the operating system is android (FIXME backtraces broken on the Android bot #17520)) (J1)
  • [debuginfo-gdb] tests/debuginfo/multiline-calls.rs: [missing] -> pass (J2)
  • [debuginfo-gdb (split-dwarf)] tests/debuginfo/multiline-calls.rs: [missing] -> ignore (ignored when the GDB version is lower than 16.0) (J4)
  • [debuginfo-cdb] tests/debuginfo/multiline-calls.rs: [missing] -> pass (J6)
  • [ui] tests/ui/panics/location-detail-unwrap-multiline.rs: [missing] -> pass (J8)
  • [debuginfo-lldb] tests/debuginfo/multiline-calls.rs: [missing] -> pass (J9)

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 5e16c662062fd6dee91f0fe2a1580483488d80cf --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. aarch64-apple: 3682.4s -> 4197.9s (14.0%)
  2. x86_64-apple-1: 7930.2s -> 6837.1s (-13.8%)
  3. x86_64-mingw-2: 7128.7s -> 7709.8s (8.2%)
  4. dist-x86_64-msvc-alt: 7995.3s -> 7404.3s (-7.4%)
  5. dist-apple-various: 5448.8s -> 5838.1s (7.1%)
  6. x86_64-gnu-debug: 6245.6s -> 5863.7s (-6.1%)
  7. dist-i686-mingw: 7866.6s -> 8331.2s (5.9%)
  8. x86_64-gnu-llvm-20-2: 6149.8s -> 5824.2s (-5.3%)
  9. dist-aarch64-apple: 5052.8s -> 5275.6s (4.4%)
  10. x86_64-msvc-ext2: 5858.3s -> 5635.1s (-3.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5e16c66): comparison URL.

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

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.2% [0.2%, 0.3%] 2
Regressions ❌
(secondary)
2.9% [2.8%, 3.0%] 2
Improvements ✅
(primary)
-2.8% [-2.8%, -2.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-2.8%, 0.3%] 3

Max RSS (memory usage)

Results (primary 3.7%, secondary 3.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)
3.7% [3.3%, 3.9%] 3
Regressions ❌
(secondary)
3.0% [1.9%, 6.4%] 14
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.7% [3.3%, 3.9%] 3

Cycles

Results (primary -0.5%, secondary 3.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)
1.7% [1.7%, 1.7%] 1
Regressions ❌
(secondary)
3.7% [3.4%, 3.9%] 2
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.5% [-2.6%, 1.7%] 2

Binary size

Results (primary 0.0%, secondary 0.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)
0.1% [0.0%, 0.1%] 23
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 10
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-1.1%, 0.1%] 24

Bootstrap: 775.41s -> 775.893s (0.06%)
Artifact size: 366.27 MiB -> 366.32 MiB (0.01%)

@rustbot rustbot added the perf-regression Performance regression. label May 24, 2025
@rylev
Copy link
Member

rylev commented May 27, 2025

@khuey @jieyouxu the big improvement is noise, but some of the regressions seem legit. It seems like perhaps more time is being spent in codegen_module which I suspect tracks well with the change here. Thoughts on possible ways to mitigate the regressions here?

@jieyouxu
Copy link
Member

Hm, interesting, I suppose we are indeed generating more debuginfo? 🤔

jieyouxu added a commit to jieyouxu/rust that referenced this pull request May 27, 2025
…youxu"

This reverts commit 5e16c66, reversing
changes made to 038d599.
bors added a commit that referenced this pull request May 27, 2025
[PERF] Revert "Auto merge of #141372 - khuey:ir_call_dbg_loc, r=jieyouxu"

This reverts commit 5e16c66, reversing changes made to 038d599.

r? `@ghost`
@khuey
Copy link
Contributor Author

khuey commented May 27, 2025

What does tt_muncher actually do? If it has a lot of function callsites this would make sense.

@Kobzol
Copy link
Contributor

Kobzol commented May 27, 2025

@khuey
Copy link
Contributor Author

khuey commented May 27, 2025

There are only a handful of calls in tt_muncher and this PR adds exactly one new metadata node to the LLVM IR that produces the final binary ... But the line I added in this PR executes 5659 times on tt_muncher (as opposed to 9 times on a "Hello, world!" program).

How does the macro work? Does that get compiled into code and executed and thrown away? Do we generate debug info for that code?

@jieyouxu
Copy link
Member

jieyouxu commented May 28, 2025

How does the macro work? Does that get compiled into code and executed and thrown away? Do we generate debug info for that code?

That is a modified version intended to stress test macro expansion: https://github.com/rust-lang/rustc-perf/blob/9cae27ac44e0adfec64826dfcb005ea69896643a/collector/compile-benchmarks/tt-muncher/quote-1.0.17-modified/src/lib.rs#L120-L129

Which is then exercised by https://github.com/rust-lang/rustc-perf/blob/9cae27ac44e0adfec64826dfcb005ea69896643a/collector/compile-benchmarks/tt-muncher/src/main.rs#L7 which AFAICT would trigger a lot of calls.

@jieyouxu
Copy link
Member

jieyouxu commented May 28, 2025

Thoughts on possible ways to mitigate the regressions here?

I'm not too sure for this case tbh:

  • To get more precise debuginfo we necessarily have to do more work. In stress tests like tt_muncher, this seems expensive.
  • We could consider a revert, but I'm not sure if there is really a better implementation if you want the same granularity of debuginfo.

@jieyouxu
Copy link
Member

jieyouxu commented May 29, 2025

@khuey @jieyouxu the big improvement is noise, but some of the regressions seem legit. It seems like perhaps more time is being spent in codegen_module which I suspect tracks well with the change here. Thoughts on possible ways to mitigate the regressions here?

@rylev for the time being, I think having more precise debuginfo justifies the perf hit. We are necessarily doing more work and generating more information for LLVM to digest. If we find that users report real world crates to exhibit even worse regressions, then I think we could consider a revert then. I'll keep an eye out for bug reports re. this.

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-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

8 participants