Skip to content

Add some track_caller info to precondition panics #129658

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 28, 2025

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Aug 27, 2024

Currently, when you encounter a precondition check, you'll always get the caller location of the implementation of the precondition checks. But with this PR, you'll be told the location of the invalid call. Which is useful.

I thought of this while looking at #129642 (comment).

The changes to tests/ui/const* happen because the const-eval interpreter skips #[track_caller] frames in its backtraces.

The perf implications of this are:

  • Increased debug binary sizes. The caller_location implementation requires that the additional data we want to display here be stored in const allocations, which are deduplicated but not across crates. There is no impact on optimized build sizes. The panic path and the caller location data get optimized out.
  • The compile time hit to opt-incr-patched bitmaps happens because the patch changes the line number of some function calls with precondition checks, causing us to go from 0 dirty CGUs to 1 dirty CGU.
  • The other compile time hits are marginal but real, and due to doing a handful of new queries. Adding more useful data isn't completely free.

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 27, 2024
@rust-log-analyzer

This comment has been minimized.

@saethlin
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 Aug 27, 2024
@bors
Copy link
Collaborator

bors commented Aug 27, 2024

⌛ Trying commit 18e2a95 with merge 7798f9b...

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 27, 2024
Add some track_caller info to precondition panics

r? `@ghost`

Thought of this while looking at rust-lang#129642 (comment)
@bors
Copy link
Collaborator

bors commented Aug 27, 2024

☀️ Try build successful - checks-actions
Build commit: 7798f9b (7798f9b35d0cd727f26631c015620e3dfe62e1f6)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7798f9b): comparison URL.

Overall result: no relevant changes - 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 benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary -2.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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-3.1%, -2.3%] 2
All ❌✅ (primary) - - 0

Cycles

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

Binary size

Results (primary 0.1%, secondary 0.1%)

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.6%] 47
Regressions ❌
(secondary)
0.1% [0.0%, 0.4%] 35
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.6%] 47

Bootstrap: 749.925s -> 752.783s (0.38%)
Artifact size: 338.74 MiB -> 338.79 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 27, 2024
@saethlin
Copy link
Member Author

That looks possibly acceptable. Let's just see how bad this becomes?

@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 Aug 27, 2024
@bors
Copy link
Collaborator

bors commented Aug 27, 2024

⌛ Trying commit 197c7b3 with merge 0e77a71...

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 27, 2024
Add some track_caller info to precondition panics

r? `@ghost`

Thought of this while looking at rust-lang#129642 (comment)
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Aug 27, 2024

☀️ Try build successful - checks-actions
Build commit: 0e77a71 (0e77a71199b6b2f7fac064cdf0b55e84d7ccca61)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0e77a71): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

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 a highly reliable metric that was used to determine the overall result at the top of this comment.

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

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

Results (primary 0.3%, secondary 0.1%)

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.3% [0.0%, 1.4%] 65
Regressions ❌
(secondary)
0.1% [0.0%, 0.5%] 35
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.0%, 1.4%] 65

Bootstrap: 749.925s -> 751.312s (0.18%)
Artifact size: 338.74 MiB -> 338.81 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 27, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jhpratt
Copy link
Member

jhpratt commented May 24, 2025

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented May 24, 2025

📌 Commit e36dc78 has been approved by jhpratt

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 May 24, 2025
bors added a commit that referenced this pull request May 25, 2025
Add some track_caller info to precondition panics

Currently, when you encounter a precondition check, you'll always get the caller location of the implementation of the precondition checks. But with this PR, you'll be told the location of the invalid call. Which is useful.

I thought of this while looking at #129642 (comment).

The changes to `tests/ui/const*` happen because the const-eval interpreter skips `#[track_caller]` frames in its backtraces.

The perf implications of this are:
* Increased debug binary sizes. The caller_location implementation requires that the additional data we want to display here be stored in const allocations, which are deduplicated but not across crates. There is no impact on optimized build sizes. The panic path and the caller location data get optimized out.
* The compile time hit to opt-incr-patched bitmaps happens because the patch changes the line number of some function calls with precondition checks, causing us to go from 0 dirty CGUs to 1 dirty CGU.
* The other compile time hits are marginal but real, and due to doing a handful of new queries. Adding more useful data isn't completely free.
@bors
Copy link
Collaborator

bors commented May 25, 2025

⌛ Testing commit e36dc78 with merge 6f12eca...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 25, 2025

💔 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 May 25, 2025
@rust-log-analyzer

This comment has been minimized.

@saethlin
Copy link
Member Author

@bors try

@bors
Copy link
Collaborator

bors commented May 27, 2025

⌛ Trying commit 6d0e04d with merge 1cd73d5...

bors added a commit that referenced this pull request May 27, 2025
Add some track_caller info to precondition panics

Currently, when you encounter a precondition check, you'll always get the caller location of the implementation of the precondition checks. But with this PR, you'll be told the location of the invalid call. Which is useful.

I thought of this while looking at #129642 (comment).

The changes to `tests/ui/const*` happen because the const-eval interpreter skips `#[track_caller]` frames in its backtraces.

The perf implications of this are:
* Increased debug binary sizes. The caller_location implementation requires that the additional data we want to display here be stored in const allocations, which are deduplicated but not across crates. There is no impact on optimized build sizes. The panic path and the caller location data get optimized out.
* The compile time hit to opt-incr-patched bitmaps happens because the patch changes the line number of some function calls with precondition checks, causing us to go from 0 dirty CGUs to 1 dirty CGU.
* The other compile time hits are marginal but real, and due to doing a handful of new queries. Adding more useful data isn't completely free.

try-job: test-various
@saethlin saethlin 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 27, 2025
@bors
Copy link
Collaborator

bors commented May 27, 2025

☀️ Try build successful - checks-actions
Build commit: 1cd73d5 (1cd73d518b9babf013044d90e9d757a210a41214)

@saethlin
Copy link
Member Author

@bors r=jhpratt

@bors
Copy link
Collaborator

bors commented May 27, 2025

📌 Commit 6d0e04d has been approved by jhpratt

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 27, 2025
@bors
Copy link
Collaborator

bors commented May 27, 2025

⌛ Testing commit 6d0e04d with merge be42293...

@bors
Copy link
Collaborator

bors commented May 28, 2025

☀️ Test successful - checks-actions
Approved by: jhpratt
Pushing be42293 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 28, 2025
@bors bors merged commit be42293 into rust-lang:master May 28, 2025
8 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 28, 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 45f256d (parent) -> be42293 (this PR)

Test differences

Show 2448 test diffs

2448 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard be422939446d7c5b27ba98debb6b4b8d6a261f1a --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-gnu: 6386.1s -> 8098.2s (26.8%)
  2. aarch64-gnu-debug: 4005.6s -> 4950.7s (23.6%)
  3. dist-aarch64-apple: 6589.2s -> 5537.3s (-16.0%)
  4. dist-apple-various: 8252.1s -> 7289.1s (-11.7%)
  5. x86_64-mingw-2: 7027.3s -> 7622.8s (8.5%)
  6. dist-i686-mingw: 8764.8s -> 8117.7s (-7.4%)
  7. x86_64-msvc-ext1: 7718.6s -> 7204.1s (-6.7%)
  8. x86_64-apple-2: 5063.5s -> 4730.0s (-6.6%)
  9. dist-x86_64-mingw: 7534.3s -> 7967.5s (5.7%)
  10. x86_64-gnu-llvm-20-2: 5942.4s -> 6279.6s (5.7%)
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 (be42293): comparison URL.

Overall result: ❌ regressions - 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)
1.0% [0.1%, 6.2%] 14
Regressions ❌
(secondary)
0.8% [0.4%, 1.2%] 4
Improvements ✅
(primary)
-0.5% [-0.5%, -0.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.9% [-0.5%, 6.2%] 15

Max RSS (memory usage)

Results (primary 1.0%, secondary 3.6%)

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.9% [0.9%, 6.7%] 6
Regressions ❌
(secondary)
3.6% [2.2%, 5.1%] 2
Improvements ✅
(primary)
-4.7% [-5.7%, -3.7%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.0% [-5.7%, 6.7%] 8

Cycles

Results (primary 5.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)
5.7% [3.3%, 8.2%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.7% [3.3%, 8.2%] 2

Binary size

Results (primary 0.6%, secondary 1.3%)

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.6% [0.0%, 2.8%] 66
Regressions ❌
(secondary)
1.3% [0.1%, 2.9%] 25
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [0.0%, 2.8%] 66

Bootstrap: 779.523s -> 779.377s (-0.02%)
Artifact size: 366.37 MiB -> 366.47 MiB (0.03%)

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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library 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