-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Use ZST for fmt unsafety #89139
Use ZST for fmt unsafety #89139
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
r? @scottmcm (rust-highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit dbfddbabc542aa6700738dc908423dfa924589b9 with merge f6eea4b87f48729f8ba6d9bc07003e4763f92b75... |
☀️ Try build successful - checks-actions |
Queued f6eea4b87f48729f8ba6d9bc07003e4763f92b75 with parent e7958d3, future comparison URL. |
Finished benchmarking commit (f6eea4b87f48729f8ba6d9bc07003e4763f92b75): comparison url. Summary: This change led to moderate relevant improvements 🎉 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 led to changes in compiler perf. @bors rollup=never |
r=me with an expanded comment on the UnsafeArg constructor. I think we should basically say something like "must be used for at most one call to new_v1_formatted, and created only if the other arguments meet the preconditions", with ideally those preconditions documented somewhere but for now we can just put in a FIXME for that. |
dbfddba
to
45a3f49
Compare
This allows the format_args! macro to keep the pre-expansion code out of the unsafe block without doing gymnastics with nested `match` expressions. This reduces codegen.
45a3f49
to
09b37d7
Compare
@bors r=Mark-Simulacrum |
📌 Commit 09b37d7 has been approved by |
The job Click to see the possible cause of the failure (guessed by this bot)
|
☀️ Test successful - checks-actions |
Finished benchmarking commit (67365d6): comparison url. Summary: This change led to large relevant mixed results 🤷 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
Regressions in deeply-nested-async appear to be due to extra instructions in the type privacy visitor, presumably caused by the println! expanding to include an additional type after this PR. That then creates extra work for the visitor. Regressions in ctfe-stress have no such obvious cause, and the test doesn't actually contain any println!s. The self-profile view shows this as increasing the number of specializes queries, which is somewhat surprising; it looks like all specializes queries on this benchmark are coming from typeck > evaluation_obligation > specializes based on self-profile results. My best guess is that the code here is the cause of the regression: presumably, we're trying to eliminate a newly added impl when checking some ImplCandidate. I compiled locally with before/after and -Zself-profile-events=all to get the inputs to both queries which produces some pretty weird results. For the record, this was done with rust-lang/rustc-perf#1031 and then using: ./target/release/collector diff_local self-profile +30278d3cf92b581550933546370443a5d5700002 +67365d64bcdfeae1334bf2ff49587c27d1c973f0 --include ctfe-stress-4 --builds Check --runs Full
mmview ./results/Zsp-30278d3cf92b581550933546370443a5d5700002-ctfe-stress-4-Check-Full/Zsp.mm_profdata | rg 'label: specializes' -A1 | rg additional_data > before
mmview ./results/Zsp-67365d64bcdfeae1334bf2ff49587c27d1c973f0-ctfe-stress-4-Check-Full/Zsp.mm_profdata | rg 'label: specializes' -A1 | rg additional_data > after
diff -u <(sort ./base) <(sort ./after) > query.diff I put up the diff here, but it shows some pretty weird inconsistencies that I wouldn't have expected from this PR -- my expectation would be that the specializes() query here is invoked deterministically, but that doesn't seem to be the case, or these indices are off. That said, all the changes in invocation are from core::ops::bit, which is not changed by this PR (right?) -- not even impls should be getting added in there. There's some discussion on this particular topic on Zulip - https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/defpath.20printing |
Zulip discussion indicates that the shifts in indices are not unexpected. I still don't have a good explanation for why there's extra queries though -- that seems like it shouldn't happen for the changes in this PR, perhaps suggesting that trait resolution is somehow being affected here :/ |
Okay, upon rebuilding before/after locally with debug logging enabled and some investigation, I'm pretty sure that the delta in query counts here was due to this landing before #89016 which fixed some "noise" in the iteration order here. That PR also reduces the amount of specializes queries (though it's not expected that this has any direct relationship to this PR); we are just seeing that there is now a hopefully more stable order. Regardless, this source of noise is now understood and we can mark this regression as triaged; we don't expect any fixes to the ctfe-stress to be possible. The previous comment already triaged the await-call-tree regression as something we're also not expecting to fix and consider acceptable. @rustbot label +perf-regression-triaged (cc @lcnr in case you wanted some additional evidence for why that was important...) |
Use ZST for fmt unsafety as suggested here - rust-lang#83302 (comment).
…-Simulacrum Add private arg to fmt::UnsafeArg As discussed [here](rust-lang#89139 (comment)) r? `@Mark-Simulacrum`
as suggested here - #83302 (comment).