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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

@bors
Copy link
Collaborator

bors commented Apr 24, 2025

☔ The latest upstream changes (presumably #140256) made this pull request unmergeable. Please resolve the merge conflicts.

@saethlin saethlin force-pushed the spare-a-crumb branch 3 times, most recently from 4d35e24 to d7ad549 Compare April 25, 2025 22:54
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 3, 2025

☔ The latest upstream changes (presumably #140596) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 20, 2025

☔ The latest upstream changes (presumably #139916) made this pull request unmergeable. Please resolve the merge conflicts.

@saethlin saethlin added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. labels May 21, 2025
@rust-lang rust-lang deleted a comment from rustbot May 21, 2025
@saethlin
Copy link
Member Author

@rustbot label: +perf-regression-triaged
See PR description

r? libs

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label May 21, 2025
@saethlin saethlin marked this pull request as ready for review May 21, 2025 13:29
@rustbot
Copy link
Collaborator

rustbot commented May 21, 2025

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@saethlin
Copy link
Member Author

To re-run on the new benchmarks:
@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 21, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 21, 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 rust-lang#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 21, 2025

⌛ Trying commit e36dc78 with merge 695a306...

@bors
Copy link
Collaborator

bors commented May 21, 2025

☀️ Try build successful - checks-actions
Build commit: 695a306 (695a3061da4318c118b7c637d9c31b33f73b7043)

@rust-timer
Copy link
Collaborator

Queued 695a306 with parent c43786c, future comparison URL.
There is currently 1 preceding artifact in the queue.
It will probably take at least ~1.9 hours until the benchmark run finishes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-perf Status: Waiting on a perf run to be completed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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