Skip to content

add const_panic macro to make it easier to fall back to non-formatting panic in const#132542

Merged
bors merged 1 commit into
rust-lang:masterfrom
RalfJung:const_panic
Nov 3, 2024
Merged

add const_panic macro to make it easier to fall back to non-formatting panic in const#132542
bors merged 1 commit into
rust-lang:masterfrom
RalfJung:const_panic

Conversation

@RalfJung

@RalfJung RalfJung commented Nov 2, 2024

Copy link
Copy Markdown
Member

Suggested by @tgross35

r? @tgross35

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 2, 2024
@rust-log-analyzer

This comment has been minimized.

Comment thread library/core/src/panic.rs Outdated
Comment thread library/core/src/panic.rs Outdated
@tgross35

tgross35 commented Nov 3, 2024

Copy link
Copy Markdown
Contributor

I am mildly amused about how similar this is to the patch I had but never finished up. Even down to both of us calling the const string "boring" in the example 😆

/// const_panic!("boring message", "flavored message {a} {b:?}", a: u32 = foo.len(), b: Something = bar);

https://github.com/tgross35/rust/blob/92e6632422a568500bcd49b03943e4ea9e6bb0ca/library/core/src/macros/mod.rs#L931-L932

@RalfJung

RalfJung commented Nov 3, 2024

Copy link
Copy Markdown
Member Author

I am mildly amused about how similar this is to the patch I had but never finished up. Even down to both of us calling the const string "boring" in the example

I copied that example from you ;)

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I copied that example from you ;)

Oh, well I guess that explains where I got it too 😄

r=me with green CI

@rust-log-analyzer

This comment has been minimized.

@RalfJung

RalfJung commented Nov 3, 2024 via email

Copy link
Copy Markdown
Member Author

@tgross35

tgross35 commented Nov 3, 2024

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Nov 3, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit bc757f9 has been approved by tgross35

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 Nov 3, 2024
@bors

bors commented Nov 3, 2024

Copy link
Copy Markdown
Collaborator

⌛ Testing commit bc757f9 with merge e3a918e...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hm, maybe I shouldn't put them in this file, since this is generally for macros that are stable / intended to be stabilized?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you have it in core::panic before? I guess that could make sense, considering most of the macros in core::panic are doc(hidden) and meant for internal use.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Okay, I've moved them in #132571.

@bors

bors commented Nov 3, 2024

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: tgross35
Pushing e3a918e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 3, 2024
@bors bors merged commit e3a918e into rust-lang:master Nov 3, 2024
@rustbot rustbot added this to the 1.84.0 milestone Nov 3, 2024
@RalfJung RalfJung deleted the const_panic branch November 3, 2024 20:45
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (e3a918e): 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.8% [0.2%, 1.8%] 6
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-0.9%, -0.1%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-0.9%, 1.8%] 11

Max RSS (memory usage)

Results (primary 3.9%, secondary 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)
5.1% [2.4%, 11.9%] 6
Regressions ❌
(secondary)
3.2% [2.7%, 3.8%] 2
Improvements ✅
(primary)
-3.4% [-3.4%, -3.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.9% [-3.4%, 11.9%] 7

Cycles

Results (primary 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)
1.7% [1.5%, 1.8%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.9% [-3.2%, -1.1%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-3.2%, 1.8%] 7

Binary size

Results (primary 0.3%, 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.4% [0.0%, 5.2%] 46
Regressions ❌
(secondary)
0.4% [0.4%, 0.4%] 3
Improvements ✅
(primary)
-0.2% [-0.5%, -0.0%] 11
Improvements ✅
(secondary)
-0.0% [-0.2%, -0.0%] 37
All ❌✅ (primary) 0.3% [-0.5%, 5.2%] 57

Bootstrap: 780.556s -> 780.261s (-0.04%)
Artifact size: 335.29 MiB -> 335.33 MiB (0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Nov 3, 2024
@rylev

rylev commented Nov 5, 2024

Copy link
Copy Markdown
Member

@RalfJung looks like most of the regressions are taking longer in LLVM related queries (e.g., LLVM_module_codegen_emit_obj) which doesn't make a ton of sense to me. Any ideas? The regressions are small enough that it could be argued we could just let this go, but I wanted to ask before marking as triaged.

@RalfJung

RalfJung commented Nov 5, 2024

Copy link
Copy Markdown
Member Author

Looking at just the first two benchmarks, this seems to have immediately gone back to the old state in the next PR.

@lqd

lqd commented Nov 5, 2024

Copy link
Copy Markdown
Member

Which graph are you looking at? Here are the first 2 benchmarks:
image
image

@RalfJung

RalfJung commented Nov 5, 2024

Copy link
Copy Markdown
Member Author

I looked at the first things it lists when clicking the "instruction count" link. But apparently I just can't read the graph. ;)

So, this PR does change the inline attributes for some of these functions. I can try tweaking them to see if that helps... but it'd be unfortunate if we have to custom-tweak them differently for different panic sites.

@RalfJung

RalfJung commented Nov 5, 2024

Copy link
Copy Markdown
Member Author

I'll do some experiments in #132662.

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. 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-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