Skip to content

Panic directly in Arguments::new* instead of recursing#117804

Merged
bors merged 1 commit into
rust-lang:masterfrom
saethlin:no-recursive-panics
May 23, 2024
Merged

Panic directly in Arguments::new* instead of recursing#117804
bors merged 1 commit into
rust-lang:masterfrom
saethlin:no-recursive-panics

Conversation

@saethlin

@saethlin saethlin commented Nov 11, 2023

Copy link
Copy Markdown
Member

This has been bothering me because it looks very silly in MIR.

@saethlin saethlin added the S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. label Nov 11, 2023
@rustbot rustbot added 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. labels Nov 11, 2023
@saethlin

Copy link
Copy Markdown
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 Nov 11, 2023
@bors

bors commented Nov 11, 2023

Copy link
Copy Markdown
Collaborator

⌛ Trying commit ca211ea with merge 3f1c95e...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 11, 2023
Panic directly in Arguments::new* instead of recursing

This has been bothering me because it looks very silly in MIR. Maybe the simpler form is faster? It surely inlines more... but is that good?

r? `@ghost`
@bors

bors commented Nov 11, 2023

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 3f1c95e (3f1c95e7f80cf85417b044bf9e22fccc8e8da9fa)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (3f1c95e): 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.5% [0.4%, 0.7%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 2
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) 0.1% [-0.4%, 0.7%] 5

Max RSS (memory usage)

Results

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.0% [0.5%, 3.3%] 8
Regressions ❌
(secondary)
2.3% [0.8%, 3.9%] 2
Improvements ✅
(primary)
-2.0% [-8.0%, -0.0%] 16
Improvements ✅
(secondary)
-3.2% [-3.2%, -3.2%] 1
All ❌✅ (primary) -1.0% [-8.0%, 3.3%] 24

Cycles

Results

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.4%, 0.4%] 1
Regressions ❌
(secondary)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
-0.6% [-1.0%, -0.4%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-1.0%, 0.4%] 5

Binary size

Results

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%, 1.6%] 30
Regressions ❌
(secondary)
0.7% [0.2%, 1.2%] 2
Improvements ✅
(primary)
-0.1% [-0.3%, -0.0%] 18
Improvements ✅
(secondary)
-0.3% [-1.8%, -0.0%] 7
All ❌✅ (primary) 0.0% [-0.3%, 1.6%] 48

Bootstrap: 674.031s -> 673.733s (-0.04%)
Artifact size: 311.12 MiB -> 311.18 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 Nov 11, 2023
@Noratrieb Noratrieb removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2024
@saethlin saethlin force-pushed the no-recursive-panics branch from ca211ea to 28561aa Compare February 14, 2024 05:14
@saethlin

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 14, 2024
Panic directly in Arguments::new* instead of recursing

This has been bothering me because it looks very silly in MIR. Maybe the simpler form is faster? It surely inlines more... but is that good?

r? `@ghost`
@bors

bors commented Feb 14, 2024

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 28561aa with merge 2d12f93...

@bors

bors commented Feb 14, 2024

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 2d12f93 (2d12f936c6b3cc86f816bc3447e7a5a79bbbcff3)

@saethlin saethlin force-pushed the no-recursive-panics branch from 28561aa to 84a3671 Compare April 5, 2024 16:27
@saethlin saethlin added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. labels Apr 5, 2024
@saethlin

saethlin commented Apr 5, 2024

Copy link
Copy Markdown
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 Apr 5, 2024
@bors

bors commented Apr 5, 2024

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 84a3671 with merge 7121f46...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 5, 2024
Panic directly in Arguments::new* instead of recursing

This has been bothering me because it looks very silly in MIR.
@bors

bors commented Apr 5, 2024

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 7121f46 (7121f46349015d3a65d1186e0977f1b80253343f)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7121f46): 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.7% [0.4%, 0.9%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.9% [-1.0%, -0.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-1.0%, 0.9%] 5

Max RSS (memory usage)

Results

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)
7.4% [3.2%, 11.6%] 2
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
-5.7% [-7.4%, -3.7%] 3
Improvements ✅
(secondary)
-1.4% [-1.6%, -1.3%] 2
All ❌✅ (primary) -0.4% [-7.4%, 11.6%] 5

Cycles

Results

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.8% [0.8%, 0.8%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.0% [-1.0%, -1.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-1.0%, 0.8%] 2

Binary size

Results

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

Bootstrap: 668.884s -> 667.893s (-0.15%)
Artifact size: 318.05 MiB -> 318.07 MiB (0.01%)

@rust-log-analyzer

This comment has been minimized.

@saethlin

Copy link
Copy Markdown
Member Author

r-l-a reported the wrong chunk:

  error[E0015]: cannot call non-const fn `intrinsics::abort` in constant functions
     --> library/core/src/fmt/mod.rs:345:13
      |
  345 |             crate::intrinsics::abort();
      |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

@joboet how should I abort in a const fn?

@joboet

joboet commented May 23, 2024

Copy link
Copy Markdown
Member

Ah, I see... then how about panicking::panic_nounwind?

@saethlin saethlin force-pushed the no-recursive-panics branch from e2c1008 to bff3625 Compare May 23, 2024 13:20
@rustbot

rustbot commented May 23, 2024

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/cargo

cc @ehuss

@saethlin saethlin force-pushed the no-recursive-panics branch from bff3625 to 75f3cef Compare May 23, 2024 13:21
@saethlin

Copy link
Copy Markdown
Member Author

Accidentally snagged a submodule change in my haste.

@joboet

joboet commented May 23, 2024

Copy link
Copy Markdown
Member

Thank you!
@bors r+
r? joboet

@bors

bors commented May 23, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit 75f3cef has been approved by joboet

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

bors commented May 23, 2024

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 75f3cef with merge 606afbb...

@@ -340,7 +340,9 @@ impl<'a> Arguments<'a> {
#[rustc_const_unstable(feature = "const_fmt_arguments_new", issue = "none")]
pub const fn new_const(pieces: &'a [&'static str]) -> Self {

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.

Is there a reason it can't be

Suggested change
pub const fn new_const(pieces: &'a [&'static str]) -> Self {
pub const fn new_const(pieces: &'a [&'static str; 1]) -> Self {

eliminating the "runtime" check?

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.

This function currently is called with references to arrays of length 1 and 0. This is a decent idea, but at least it would require some amount of surgery on the format_args! expansion code.

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.

Ah, right, I overlooked 0 being valid as well.

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.

What about then?

Suggested change
pub const fn new_const(pieces: &'a [&'static str]) -> Self {
pub const fn new_const<const N: usize>(pieces: &'a [&'static str; N]) -> Self {

After monomorphization the check should be eliminat-able this way, though I suspect this function is probably small enough to be probably always inlined anyways, making this point moot.

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.

Hunh. That's a really good idea.

@bors

bors commented May 23, 2024

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: joboet
Pushing 606afbb to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 23, 2024
@bors bors merged commit 606afbb into rust-lang:master May 23, 2024
@rustbot rustbot added this to the 1.80.0 milestone May 23, 2024
@saethlin saethlin deleted the no-recursive-panics branch May 23, 2024 19:28
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (606afbb): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

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

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.3% [0.3%, 0.3%] 2
Regressions ❌
(secondary)
0.4% [0.1%, 0.9%] 9
Improvements ✅
(primary)
-0.5% [-0.5%, -0.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.5%, 0.3%] 3

Max RSS (memory usage)

Results (primary -0.7%, secondary -5.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)
3.6% [1.0%, 7.0%] 5
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-7.7% [-10.7%, -3.3%] 3
Improvements ✅
(secondary)
-5.6% [-5.6%, -5.6%] 1
All ❌✅ (primary) -0.7% [-10.7%, 7.0%] 8

Cycles

Results (primary -3.3%, secondary -2.5%)

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

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.2% [0.0%, 0.5%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-1.0%, -0.0%] 46
Improvements ✅
(secondary)
-0.1% [-0.5%, -0.0%] 8
All ❌✅ (primary) -0.1% [-1.0%, 0.5%] 49

Bootstrap: 673.733s -> 672.526s (-0.18%)
Artifact size: 315.79 MiB -> 315.69 MiB (-0.03%)

@saethlin

saethlin commented May 23, 2024

Copy link
Copy Markdown
Member Author

@rustbot label: +perf-regression-triaged

No cycles regressions. The small bit of jitter was expected based on poking the size of a common function's MIR. The 7 match-stress secondary regressions are unexpected, but the cachegrind diff attributes all changes in those to rustc_hir_analysis::check::check::check_item_type which makes this seem like inliner noise. Unclear how to investigate further. The check regression in tt-muncher produces a cachegrind diff that reports a decrease in instructions, and the the debug regression in tt-muncher reports the entire regression is in memmove. Unclear what to make of that.

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label May 23, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 24, 2024
…t, r=<try>

Move the checks for Arguments constructors to inline const

Thanks `@Skgland` for pointing out this opportunity: rust-lang#117804 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2024
…t, r=joboet

Move the checks for Arguments constructors to inline const

Thanks `@Skgland` for pointing out this opportunity: rust-lang#117804 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2024
…t, r=joboet

Move the checks for Arguments constructors to inline const

Thanks `@Skgland` for pointing out this opportunity: rust-lang#117804 (comment)
RalfJung pushed a commit to RalfJung/miri that referenced this pull request May 27, 2024
Move the checks for Arguments constructors to inline const

Thanks `@Skgland` for pointing out this opportunity: rust-lang/rust#117804 (comment)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Jun 28, 2024
Move the checks for Arguments constructors to inline const

Thanks `@Skgland` for pointing out this opportunity: rust-lang/rust#117804 (comment)
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.

9 participants