Cache const-eval local layouts per instance - #161481
Closed
anonrig wants to merge 2 commits into
Closed
Conversation
Repeated calls to the same monomorphic const fn re-computed each local's layout because the per-frame cell starts empty. Cache layouts by (Instance, Option<Promoted>) so later invocations skip instantiate and layout_of.
Collaborator
Collaborator
|
|
Collaborator
|
Thanks for the pull request, and welcome! The Rust Project has assigned @RalfJung (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. |
Cell::set does not need a mutable locals binding, and rustc treats warnings as errors in this crate.
Member
What does this have to do with anything? This comment makes no sense. Please read our LLM policy and let me know if and how LLMs were used in generating any part of this PR. |
Author
|
Updating pr description. Sorry for the confusion! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repeated calls to the same monomorphic
const fncurrently re-compute the layout of every local on each invocation:LocalState::layoutis a per-frame cell and starts empty when the frame is pushed.This adds a per-interpreter cache keyed by instance and optional promoted index. The first call fills it; later calls prefill the frame cells and skip instantiate +
layout_of.This is the remaining miss after the per-interpreter type layout cache (#157275). Large
consttables that call small helpers (f64::from_bits, outlined math) currently hitlayout_of_localonce per call instead of once per instance — see #157010 (image,moxcms/pxfm).Local same-commit stage1 measurements (
--edition=2024 --crate-type=bin --emit=metadata, median of 3 after warmup):update_sumtable, N=2^16update_sumtable, N=2^18f64::from_bitshelper × 3 × 2^17The leftover outlined-vs-inlined gap is interpreter call overhead, not layout. The cache removes the redundant
layout_of_localwork described in #157010.Not stacked on #161477. Different subsystem (CTFE layouts, not next-solver fulfillment).
r? RalfJung