-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 auto-inline const functions #56024
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
6c84600
to
2b55e51
Compare
This comment has been minimized.
This comment has been minimized.
64451e0
to
6f0c41a
Compare
This comment has been minimized.
This comment has been minimized.
6f0c41a
to
eb18ddd
Compare
r? @eddyb |
Hm, the approach doesn't seem quite right to me. With the PR we would translate all const fns to machine code, even if they are never used anywhere. That would add code bloat. Shouldn't we be able to handle this like we handle regular |
We also translate normal functions without If we start creating more complex const fns, they would get codegened multiple times if they are auto-inlined without any way to opt back out of the implicit inlining |
Only, if they are publicly visible.
Yes, that's true. Let's do a perf run. I still think this PR is more of a work-around than a real solution to the problem. The compiler should be able to handle both cases. That it doesn't seems like a bug. |
@bors try |
⌛ Trying commit eb18ddd with merge 5720c63ceb9a7b0029646d8a61763ae27f358b2f... |
Yes indeed. I was going to fix the real thing and questioned the motive of auto-inlining const fns while I was doing so. Thus this PR
The bug is code asking whether functions have an |
☀️ Test successful - status-travis |
@rust-timer build 5720c63 |
Please provide the full 40 character commit hash. |
@rust-timer build 5720c63ceb9a7b0029646d8a61763ae27f358b2f |
Success: Queued 5720c63ceb9a7b0029646d8a61763ae27f358b2f with parent 289ad6e, comparison URL. |
Finished benchmarking try commit 5720c63ceb9a7b0029646d8a61763ae27f358b2f |
2% perf improvement on some benchmarks, 1% regression on +14% to -6% max memory usage, pretty wild results: https://perf.rust-lang.org/compare.html?start=289ad6e9922683807d455ca0020dc2a8f7bd1a7b&end=5720c63ceb9a7b0029646d8a61763ae27f358b2f&stat=max-rss |
Many of those max-rss benchmarks seem to be very flaky to begin with, especially OK, let's do this. Const fns that are only every used in a const context and are not publicly visible should still never be instantiated (because the collector won't find any calls to them in that case). @bors r+ |
📌 Commit eb18ddd has been approved by |
⌛ Testing commit eb18ddd with merge a7cc9ff7aeaeac0dc2b706f7ccd56cf555cd1e9f... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry network test spuriously thinking it was able to connect |
…ichaelwoerister Don't auto-inline const functions fixes rust-lang#53451
Rollup of 14 pull requests Successful merges: - #56024 (Don't auto-inline const functions) - #56045 (Check arg/ret sizedness at ExprKind::Path) - #56072 (Stabilize macro_literal_matcher) - #56075 (Encode a custom "producers" section in wasm files) - #56100 (generator fields are not necessarily initialized) - #56101 (Incorporate `dyn` into more comments and docs.) - #56144 (Fix BTreeSet and BTreeMap gdb pretty-printers) - #56151 (Move a flaky process test out of libstd) - #56170 (Fix self profiler ICE on Windows) - #56176 (Panic setup msg) - #56204 (Suggest correct enum variant on typo) - #56207 (Stabilize the int_to_from_bytes feature) - #56210 (read_c_str should call the AllocationExtra hooks) - #56211 ([master] Forward-ports from beta) Failed merges: r? @ghost
fixes #53451