-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Don't walk the bodies of free constants for reachability. #122505
Conversation
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Don't walk the bodies of free constants for reachability. follow-up to rust-lang#122371 we don't have generic constants yet, so we don't need to handle failure to eval a free constant. Associated consts and generic consts will be a different topic, that I will look into in a follow-up r? `@tmiasko`
What about |
Yea, those xD. I keep forgetting they already exist. Will add a test that hits my new |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (5620969): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking 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 @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Binary sizeResultsThis 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.
Bootstrap: 669.602s -> 670.27s (0.10%) |
d46c98d
to
bdd257c
Compare
Left a question in a review comment, but other than that r=me. Thanks. |
bdd257c
to
66cca33
Compare
@bors r=tmiasko |
This comment has been minimized.
This comment has been minimized.
huh... this still worked yesterday and is failing now... |
Minimized reproducer (doesn't require changes from this pull request): $ cat a.rs
pub static A: fn() -> fn() = {
const {
#[inline(never)]
fn f() {}
|| -> fn() { f }
}
};
$ cat b.rs
static A: fn() -> fn () = a::A;
fn main() { A()() }
$ rustc a.rs --crate-type=lib -Zprint-mono-items=lazy -O
MONO_ITEM fn <{closure@a.rs:5:9: 5:19} as std::ops::FnOnce<()>>::call_once - shim @@ a.a67665f9196cd4be-cgu.0[Internal]
MONO_ITEM fn A::f @@ a.a67665f9196cd4be-cgu.0[Internal]
MONO_ITEM fn A::{closure#0} @@ a.a67665f9196cd4be-cgu.0[Internal]
MONO_ITEM static A @@ a.a67665f9196cd4be-cgu.0[External]
$ rustc b.rs --crate-type=bin --extern a -L.
error: missing optimized MIR for an item in the crate `a`
|
note: missing optimized MIR for this item (was the crate `a` compiled with `--emit=metadata`?)
--> /tmp/a.rs:4:9
|
4 | fn f() {}
| ^^^^^^
error: aborting due to 1 previous error
$ rustc --version
rustc 1.80.0-nightly (7c52d2db6 2024-06-03) |
oof, I hope this isn't hitting stable next week. Tho it would be easy to fix |
66cca33
to
a0358f4
Compare
@bors r=tmiasko |
☀️ Test successful - checks-actions |
Finished benchmarking commit (d0ccb54): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (primary 2.8%, secondary -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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 667.497s -> 669.842s (0.35%) |
This had a few instruction count wins, and also binary size wins before merge, but no binary size wins after merge. Was that expected? In any case, the regression is small and only on a single benchmark, so I don't need that we need to investigate further, just wanted to ask, especially about the missing binary size wins. |
I don't think I understand why being a free constant vs an associated constant makes a difference here. Even for free constants we store their MIR, not their computed result, in the rmeta, right? |
Ah I think I get it... I have clarified the comments in #126259. |
Yea, we could evaluate associated constants, often even generic ones can be evaluated to a concrete value. |
Sure, but that would be a pretty fundamental departure from our current evaluation strategy.
|
Marking as triaged after a discussion with Oli, the small perf. regression is expected. @rustbot label: +perf-regression-triaged |
reachable computation: clarify comments around consts Follow-up to rust-lang#122505
Rollup merge of rust-lang#126259 - RalfJung:reachable-const, r=oli-obk reachable computation: clarify comments around consts Follow-up to rust-lang#122505
follow-up to #122371
cc #119214
This avoids codegening items (e.g. functions) that are only used during const eval, but do not reach their final constant value (e.g. via function pointers).
r? @tmiasko