Skip to content

Streamline the format macro. #140188

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 1 commit into from
Apr 30, 2025
Merged

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Apr 23, 2025

Removing the unnecessary local variable speeds up compilation a little.

r? @cuviper

@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 Apr 23, 2025
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the streamline-format-macro branch from b44e43c to 219714d Compare April 23, 2025 06:30
@klensy
Copy link
Contributor

klensy commented Apr 23, 2025

Scope was added in #64856 without comment, so there no issues with somehow reverting it back?

@nnethercote
Copy link
Contributor 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 23, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2025
… r=<try>

Streamline the `format` macro.

Removing the unnecessary local variable speeds up compilation a little.

r? `@ghost`
@bors
Copy link
Collaborator

bors commented Apr 23, 2025

⌛ Trying commit 219714d with merge 77bade5...

@nnethercote
Copy link
Contributor Author

Scope was added in #64856 without comment, so there no issues with somehow reverting it back?

I'm not sure. All the tests pass. Unlike back then, the block is now within the must_use call, giving an extra scope. The block itself is load-bearing; if I remove the { and } it slightly changes some error messages.

@bors
Copy link
Collaborator

bors commented Apr 23, 2025

☀️ Try build successful - checks-actions
Build commit: 77bade5 (77bade583880b062742296c0e9a2dc4cd1a389b3)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (77bade5): 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.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
1.8% [1.7%, 1.9%] 6
Improvements ✅
(primary)
-0.3% [-0.4%, -0.1%] 13
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) -0.2% [-0.4%, 0.2%] 14

Max RSS (memory usage)

Results (primary 2.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)
3.5% [0.7%, 12.2%] 10
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.3% [-3.4%, -1.5%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.1% [-3.4%, 12.2%] 13

Cycles

Results (primary -0.0%, secondary -2.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)
0.4% [0.4%, 0.4%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-0.5%, -0.4%] 2
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) -0.0% [-0.5%, 0.4%] 4

Binary size

Results (primary -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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.2%, -0.0%] 15
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-0.2%, -0.0%] 15

Bootstrap: 776.892s -> 774.802s (-0.27%)
Artifact size: 365.04 MiB -> 365.02 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 23, 2025
@cuviper
Copy link
Member

cuviper commented Apr 23, 2025

Scope was added in #64856 without comment, so there no issues with somehow reverting it back?

It is probably now benefiting from the 2024 scope change:
https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html

@nnethercote
Copy link
Contributor Author

The cargo-0.60.0 perf improvement is real. That was the motivating example -- I did some ad hoc profiling of where expressions are created and found that format! calls accounted for ~1% of all expressions created when compiling that benchmark.

The match-stress regression is puzzling. I can't reproduce when I profile local builds. When I run the Cachegrind repro command to profile the CI builds it says the difference is entirely in rustc_pattern_analysis::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis::rustc::RustcPatCtxt>::{closure#0}. There is no line-level info, I think closure#0 is just |r| !r.pats.relevant so no idea what's happening there.

Removing the unnecessary local variable speeds up compilation a little.
@nnethercote nnethercote force-pushed the streamline-format-macro branch from 219714d to bc8df50 Compare April 27, 2025 20:56
@nnethercote
Copy link
Contributor 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 27, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 27, 2025
… r=<try>

Streamline the `format` macro.

Removing the unnecessary local variable speeds up compilation a little.

r? `@ghost`
@bors
Copy link
Collaborator

bors commented Apr 27, 2025

⌛ Trying commit bc8df50 with merge 42bd627...

@bors
Copy link
Collaborator

bors commented Apr 27, 2025

☀️ Try build successful - checks-actions
Build commit: 42bd627 (42bd6276c0918c5943c8e76015a4bf68af24177f)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (42bd627): 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
Regressions ❌
(secondary)
1.8% [1.7%, 1.9%] 6
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 3

Max RSS (memory usage)

Results (primary 1.5%, secondary 2.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)
2.8% [0.6%, 8.4%] 5
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
-1.9% [-2.9%, -0.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [-2.9%, 8.4%] 7

Cycles

Results (primary 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)
0.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.4%, 0.4%] 1

Binary size

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)
0.1% [0.1%, 0.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.2%, -0.0%] 18
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.2%, 0.1%] 19

Bootstrap: 761.979s -> 763.313s (0.18%)
Artifact size: 365.07 MiB -> 365.10 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 28, 2025
@nnethercote nnethercote marked this pull request as ready for review April 28, 2025 01:01
@nnethercote
Copy link
Contributor Author

I think it's worth doing this for the small improvements on real-world code, which outweigh the weird regression on one artificial stress test.

@cuviper
Copy link
Member

cuviper commented Apr 29, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 29, 2025

📌 Commit bc8df50 has been approved by cuviper

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

bors commented Apr 30, 2025

⌛ Testing commit bc8df50 with merge 427288b...

@bors
Copy link
Collaborator

bors commented Apr 30, 2025

☀️ Test successful - checks-actions
Approved by: cuviper
Pushing 427288b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 30, 2025
@bors bors merged commit 427288b into rust-lang:master Apr 30, 2025
7 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 30, 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 f242d6c (parent) -> 427288b (this PR)

Test differences

No test diffs found

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 427288b3ce2d574847fdb41cc3184c893750e09a --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. x86_64-apple-2: 4779.7s -> 7602.6s (59.1%)
  2. x86_64-apple-1: 6471.1s -> 9212.6s (42.4%)
  3. dist-arm-linux: 5122.3s -> 4502.3s (-12.1%)
  4. dist-apple-various: 6199.5s -> 6792.8s (9.6%)
  5. dist-aarch64-apple: 5500.5s -> 5027.7s (-8.6%)
  6. aarch64-apple: 4075.8s -> 4420.9s (8.5%)
  7. dist-x86_64-mingw: 7500.0s -> 7935.5s (5.8%)
  8. i686-msvc-2: 7652.9s -> 7224.6s (-5.6%)
  9. dist-aarch64-linux: 5519.1s -> 5225.8s (-5.3%)
  10. x86_64-gnu-llvm-20-1: 5409.0s -> 5173.8s (-4.3%)
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 (427288b): 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.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
1.8% [1.7%, 1.9%] 6
Improvements ✅
(primary)
-0.3% [-0.4%, -0.1%] 10
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-0.4%, 0.2%] 11

Max RSS (memory usage)

Results (primary -0.4%, 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.0% [0.5%, 4.7%] 7
Regressions ❌
(secondary)
3.3% [3.3%, 3.3%] 1
Improvements ✅
(primary)
-2.5% [-13.1%, -0.5%] 8
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 1
All ❌✅ (primary) -0.4% [-13.1%, 4.7%] 15

Cycles

Results (primary -0.2%, secondary 2.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.9% [0.5%, 1.3%] 2
Regressions ❌
(secondary)
2.3% [2.3%, 2.3%] 1
Improvements ✅
(primary)
-0.6% [-1.3%, -0.4%] 6
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-1.3%, 1.3%] 8

Binary size

Results (primary -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.1% [0.1%, 0.1%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 14
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-0.1%, 0.1%] 18

Bootstrap: 770.064s -> 770.662s (0.08%)
Artifact size: 365.60 MiB -> 365.58 MiB (-0.01%)

@nnethercote nnethercote deleted the streamline-format-macro branch April 30, 2025 08:53
@nnethercote
Copy link
Contributor Author

@rustbot label: +perf-regression-triaged

The improvements on primary benchmarks were deemed to outweigh the regressions on secondary benchmarks.

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Apr 30, 2025
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.

7 participants