Skip to content

Conversation

dpaoliello
Copy link
Contributor

@dpaoliello dpaoliello commented Sep 4, 2025

Previous attempts (#127316, #134770) saw binary size regressions. Maybe it'll be different this time?

@rustbot
Copy link
Collaborator

rustbot commented Sep 4, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Sep 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 4, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@Mark-Simulacrum
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Sep 4, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 4, 2025
@rust-bors
Copy link

rust-bors bot commented Sep 4, 2025

☀️ Try build successful (CI)
Build commit: 0917255 (0917255b7c3d3d8f1c57be901c49970fb3ad0028, parent: a1208bf765ba783ee4ebdc4c29ab0a0c215806ef)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0917255): comparison URL.

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

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
3.6% [0.4%, 7.6%] 264
Regressions ❌
(secondary)
3.9% [0.0%, 21.8%] 291
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-1.3%, -0.0%] 10
All ❌✅ (primary) 3.6% [0.4%, 7.6%] 264

Max RSS (memory usage)

Results (primary 2.3%, secondary 3.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [0.5%, 5.7%] 192
Regressions ❌
(secondary)
3.3% [0.6%, 7.4%] 260
Improvements ✅
(primary)
-8.7% [-8.7%, -8.7%] 1
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) 2.3% [-8.7%, 5.7%] 193

Cycles

Results (primary 3.6%, secondary 6.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.6% [1.9%, 6.8%] 149
Regressions ❌
(secondary)
6.7% [1.8%, 59.0%] 162
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-4.0%, -2.3%] 3
All ❌✅ (primary) 3.6% [1.9%, 6.8%] 149

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 466.26s -> 486.484s (4.34%)
Artifact size: 388.41 MiB -> 410.15 MiB (5.60%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 4, 2025
@dpaoliello dpaoliello marked this pull request as draft September 4, 2025 15:52
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 4, 2025
@dpaoliello
Copy link
Contributor Author

Ok, still bad: I'll try to find some time to root cause the regression

@dpaoliello
Copy link
Contributor Author

Huh, so on Windows I see a 1% binary size improvement for rustc_driver, seems like it's from tokio-rs/tracing#2555.

Digging into the Linux side of things now (may take longer since I'm less familiar with it...)

@dpaoliello
Copy link
Contributor Author

For the Linux binary size regression, it seems to be caused by a bunch of new __CALLSITE and __CALLSITE::META static fields, which get added with every use of a tracing macro (went from ~2000 to ~8000 in the driver). I'm not sure if there's an way to remove them, or prevent them from being added to the symbol table?

I'm still looking into the instruction count regression. Not sure if those statics are part of it (additional startup costs to init them or apply relocs?).

@dpaoliello
Copy link
Contributor Author

Finally figured out how to repro this locally: I needed to use the dist profile in bootstrap, as the compiler profile enables debug logging.

I confirmed this by looking at the rustc_mir_transform::coroutine::compute_layout function: before the update it had no CALLSITE or META statics associated with it, but afterwards there are 6 of each. It also increased in binary size by about 70%. If you look at the sources, there are 6 debug! statements and no other traces, so they should have been optimized away when debug logging was disabled, but haven't been (for some reason).

@Kobzol
Copy link
Member

Kobzol commented Sep 6, 2025

I think I found the issue. We need to put max_level_info = ['tracing/max_level_info', 'tracing/release_max_level_info'] into rustc_log/Cargo.toml. Could you try it please? I'll do another perf. run.

@Kobzol
Copy link
Member

Kobzol commented Sep 6, 2025

Actually, figured I could try it myself =D Hope you don't mind.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Sep 6, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 6, 2025
@rust-bors
Copy link

rust-bors bot commented Sep 6, 2025

☀️ Try build successful (CI)
Build commit: 751817a (751817af04a05c150383439a06a40218fca7b666, parent: 397f93362974d298b79e0e0cd43677014aa7b722)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (751817a): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.1%] 3
Improvements ✅
(secondary)
-0.4% [-0.7%, -0.1%] 16
All ❌✅ (primary) -0.2% [-0.2%, -0.1%] 3

Max RSS (memory usage)

Results (primary 0.2%, secondary 5.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
5.3% [5.3%, 5.3%] 1
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-1.1%, 1.5%] 2

Cycles

Results (primary 2.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.9% [2.9%, 2.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.9% [2.9%, 2.9%] 1

Binary size

Results (secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 467.607s -> 468.277s (0.14%)
Artifact size: 390.55 MiB -> 390.58 MiB (0.01%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Sep 6, 2025
@Kobzol
Copy link
Member

Kobzol commented Sep 6, 2025

Nice! I think that was it.

r? @Kobzol

@rustbot rustbot assigned Kobzol and unassigned Mark-Simulacrum Sep 6, 2025
@klensy
Copy link
Contributor

klensy commented Sep 6, 2025

This tokio-rs/tracing#2553?

Looks like before if unset debug_assertions and set max_level_info was set, -> LevelFilter::INFO
but after pr it falls into LevelFilter::TRACE.

@Kobzol
Copy link
Member

Kobzol commented Sep 6, 2025

Great find!

@klensy
Copy link
Contributor

klensy commented Sep 6, 2025

Submitting pr, i hope tracing will be updated and we can directly bump it without workarounds.

@Kobzol
Copy link
Member

Kobzol commented Sep 6, 2025

I think that the behavior of tracing does actually correspond to what the documentation says (https://docs.rs/tracing/latest/tracing/level_filters/index.html) - note the "separately for release and debug builds" part. So either we held it wrong before, or their documentation changed in the meantime.

@klensy
Copy link
Contributor

klensy commented Sep 6, 2025

tokio-rs/tracing#3373, but need to test :-)

@Kobzol
Copy link
Member

Kobzol commented Sep 6, 2025

I think that in either case, we should just set both features, to be sure.

@bors
Copy link
Collaborator

bors commented Sep 6, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

7 participants