JIT: Precompute func-app element stride in VN chunks#126920
Merged
EgorBo merged 2 commits intodotnet:mainfrom Apr 15, 2026
Merged
JIT: Precompute func-app element stride in VN chunks#126920EgorBo merged 2 commits intodotnet:mainfrom
EgorBo merged 2 commits intodotnet:mainfrom
Conversation
Precompute and cache the element size for func-app chunks (sizeof(VNFunc) + sizeof(ValueNum) * arity) in Chunk::m_funcAppElemSize, initialized once in the constructor. PointerToFuncApp now uses a single multiply by the cached stride instead of recomputing the expression on every call. This reduces work on a hot path (GetVNFunc and all VN creation sites that call PointerToFuncApp). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes Value Number (VN) func-app chunk access in the JIT by precomputing and caching the per-element stride in each ValueNumStore::Chunk, so hot helpers (notably GetVNFunc → PointerToFuncApp) avoid recomputing the stride on every access.
Changes:
- Added
Chunk::m_funcAppElemSizeto cache the func-app element stride (0 for non-func chunks). - Initialized
m_funcAppElemSizeonce in theChunkconstructor forCEA_Func{0..4}and used it for allocation sizing (Func1..4) and indexing. - Updated
PointerToFuncAppto use the cached stride for address computation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/jit/valuenum.h | Adds cached func-app element stride to Chunk and uses it in PointerToFuncApp. |
| src/coreclr/jit/valuenum.cpp | Initializes cached stride in Chunk constructor and uses it for func-app allocations (Func1..4). |
jakobbotsch
approved these changes
Apr 15, 2026
Member
Author
|
Diffs. No memory size overhead on x64 (Chunk struct remains 24 bytes), very minor impact on Chunk size on 32bit. |
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.
Precompute and cache the element size for func-app VN chunks in
Chunk::m_funcAppElemSize, initialized once in the constructor.PointerToFuncAppnow multiplies by the cached stride instead of recomputingsizeof(VNFunc) + sizeof(ValueNum) * arityon every call.This is a minor TP improvement —
PointerToFuncAppis called fromGetVNFunc(one of the hottest VN helpers, ~80 call sites) and from all VN creation paths.Note
This PR was authored with help from GitHub Copilot.