Repository navigation
[JIT] Read PGO instrumentation settings once per method - #138612
Open
pavelsavara wants to merge 1 commit into
Open
pavelsavara wants to merge 1 commit into
pavelsavara wants to merge 1 commit into
Conversation
Compute interlocked, scalable, minimal and counter-slot settings in fgPrepareToInstrumentMethod and store them in opts, instead of rereading JitConfig at each probe. Pass counter base and offset separately to CreateCounterIncrement, return schema entries rather than raw addresses from ReadHistogramAndAdvance, and route synthesized-count writes through fgShouldWriteSynthesizedCounts. Initialize compCollect64BitCounts for inlinee compilers from the inline root. compInitOptions returns early for inlinees before the field was set, yet inlinee instrumentation reads it to choose the counter width. No codegen change is intended. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
pavelsavara
requested review from
AndyAyersMS and
jkotas
and removed request for
jkotas
December 2, 2026 15:41
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the PGO instrumentation refactor.
No open issues 🎉
What changed in this PR
Refactors JIT profile-guided optimization (PGO) instrumentation to prepare for Browser ReadyToRun PGO, with no intended code-generation changes.
Changes:
- Caches profiling settings once per method.
- Separates counter addressing from updates and centralizes synthesized-count write checks.
- Makes inlinee compilers inherit the root compiler’s counter-width setting.
| File | Description |
|---|---|
src/coreclr/jit/fgprofile.cpp |
Caches settings and refactors counter addressing, histogram access, and synthesized-count checks. |
src/coreclr/jit/compiler.h |
Declares cached profiling options and the synthesized-count helper. |
src/coreclr/jit/compiler.cpp |
Initializes counter width earlier and copies it to inlinees. |
Review effort: Balanced
jkotas
approved these changes
Dec 2, 2026
This branch has not been deployed
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.
Summary
Refactor JIT PGO instrumentation plumbing in preparation for Browser ReadyToRun PGO (#137502). Codegen should not change.
JitInterlockedProfiling,JitScalableProfiling,JitCounterPaddingand the minimal-profiling settings once infgPrepareToInstrumentMethodand keep them in newopts.compPgo*fields, instead of rereadingJitConfigat every probe.CreateCounterIncrementtakes the counter base and offset separately, through a newGetProfileAddresshelper.ReadHistogramAndAdvancereturns schema entries instead of raw addresses.fgShouldWriteSynthesizedCounts.compCollect64BitCountsfrom the inline root. Onmain,compInitOptionsreturns early for inlinees before the field is set, but inlinee instrumentation reads it to choose the counter width.The follow-up in the stack adds R2R-specific addressing (counters reached through an import cell) behind these seams, so its JIT diff stays small.
Stack
This PR is the bottom layer of the Browser ReadyToRun PGO stack. #137502 is the integration PR on top.
Validation
.\build.cmd -subset clr.alljits -c Debug.\build.cmd -os browser -subset clr.crossarchtools -c Debug /p:RuntimeFlavor=CoreCLR(Wasm cross JIT)clang-format17.0.6 fromeng\formatting\download-tools.ps1on the changed JIT filesI did not run SuperPMI asmdiffs locally. The CI superpmi-diffs legs should show no diffs.
Note
This PR description was drafted with GitHub Copilot.