Skip to content

Remove 'simple array' lowering of format_args!(). #139175

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

Closed
wants to merge 1 commit into from

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Mar 31, 2025

format_args!() uses a simpler (faster to compile) lowering in simple cases. However, selecting that case is somewhat complicated, as it does not work if any argument beyond the first one contains a yield point, so we have to check for that.

As part of the solution for #92698 and #139136, it might need to get even more complicated, checking for any lifetime-extended temporaries or any const-promotable expressions.

This is an experiment to see the impact of just removing this optimization.

This has been tried before with slightly negative results, but maybe things have changed by now. :)

@m-ou-se m-ou-se added the S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. label Mar 31, 2025
@m-ou-se m-ou-se self-assigned this Mar 31, 2025
@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 Mar 31, 2025
@m-ou-se m-ou-se force-pushed the format-args-opt-remove branch from b1add46 to e039260 Compare March 31, 2025 13:41
@m-ou-se
Copy link
Member Author

m-ou-se commented Mar 31, 2025

@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 Mar 31, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 31, 2025
Remove 'simple array' lowering of format_args!().

format_args!() uses a simpler (faster to compile) lowering in simple cases. However, selecting that case is somewhat complicated, as it does not work if any argument beyond the first one contains a yield point, so we have to check for that.

As part of the solution for rust-lang#92698 and rust-lang#139136, it might need to get even more complicated, checking for any lifetime-extended temporaries or any const-promotable expressions.

This is an experiment to see the impact of just removing this optimazation.

This has been tried before with [slightly negative results](rust-lang#106770 (comment)), but maybe things have changed by now. :)
@bors
Copy link
Collaborator

bors commented Mar 31, 2025

⌛ Trying commit e039260 with merge 19f2dc7...

@rust-log-analyzer

This comment was marked as outdated.

@bors
Copy link
Collaborator

bors commented Mar 31, 2025

☀️ Try build successful - checks-actions
Build commit: 19f2dc7 (19f2dc79c8367193769b0dcdf54aa35bb22357d1)

@m-ou-se

This comment has been minimized.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 31, 2025
Remove fragile equal-pointers-unequal/*/print3.rs tests.

These tests were added in rust-lang#127003

The print3.rs tests stop working when I change implementation details of format_args!(). (For example, in rust-lang#139175 and rust-lang#139135). These tests shouldn't rely on such implementation details. It gets in the way for format_args!() improvements.

If they test anything that aren't already covered by the other tests in this directory, they should be expressed in a less fragile way that doesn't rely on internal details of format_args!().

cc `@GrigorenkoPV,` author of these tests.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 31, 2025
Remove fragile equal-pointers-unequal/*/print3.rs tests.

These tests were added in rust-lang#127003

The print3.rs tests stop working when I change implementation details of format_args!(). (For example, in rust-lang#139175 and rust-lang#139135). These tests shouldn't rely on such implementation details. It gets in the way for format_args!() improvements.

If they test anything that aren't already covered by the other tests in this directory, they should be expressed in a less fragile way that doesn't rely on internal details of format_args!().

cc ``@GrigorenkoPV,`` author of these tests.
@m-ou-se
Copy link
Member Author

m-ou-se commented Apr 1, 2025

@rust-timer build 19f2dc7

@rust-timer

This comment has been minimized.

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 1, 2025
Rollup merge of rust-lang#139176 - m-ou-se:print3, r=compiler-errors

Remove fragile equal-pointers-unequal/*/print3.rs tests.

These tests were added in rust-lang#127003

The print3.rs tests stop working when I change implementation details of format_args!(). (For example, in rust-lang#139175 and rust-lang#139135). These tests shouldn't rely on such implementation details. It gets in the way for format_args!() improvements.

If they test anything that aren't already covered by the other tests in this directory, they should be expressed in a less fragile way that doesn't rely on internal details of format_args!().

cc ``@GrigorenkoPV,`` author of these tests.
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (19f2dc7): comparison URL.

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

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 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.5% [0.1%, 1.4%] 59
Regressions ❌
(secondary)
0.2% [0.1%, 0.3%] 4
Improvements ✅
(primary)
-0.9% [-0.9%, -0.9%] 1
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) 0.4% [-0.9%, 1.4%] 60

Max RSS (memory usage)

Results (primary 1.2%, secondary -0.4%)

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.4% [1.4%, 3.8%] 4
Regressions ❌
(secondary)
1.1% [1.1%, 1.1%] 1
Improvements ✅
(primary)
-3.3% [-3.3%, -3.3%] 1
Improvements ✅
(secondary)
-1.8% [-1.8%, -1.8%] 1
All ❌✅ (primary) 1.2% [-3.3%, 3.8%] 5

Cycles

Results (primary 1.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)
1.2% [0.5%, 1.9%] 10
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.0% [-0.8%, 1.9%] 11

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.8%] 77
Regressions ❌
(secondary)
0.1% [0.0%, 0.3%] 12
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 7
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-0.4%, 0.8%] 84

Bootstrap: 776.145s -> 776.905s (0.10%)
Artifact size: 365.92 MiB -> 365.92 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 1, 2025
@m-ou-se m-ou-se removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 1, 2025
@m-ou-se m-ou-se closed this Apr 1, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 1, 2025
…try>

Remove 'simple array' lowering of format_args!() for >1 args.

This is rust-lang#139175 but keeps the 'simple array' lowering for the case with 1 argument.

This is an experiment to see the impact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. 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.

5 participants