Repository navigation
[browser][CoreCLR] Collect ReadyToRun PGO with indexed schemas - #137502
pavelsavara wants to merge 20 commits into
Conversation
Collect 64-bit IL block profiles through normal JIT instrumentation and preserve distinct intrinsic and interpreter invocation contributions. Resolve indexed R2R schemas to stable counter storage and carry the profiles through EventPipe, MIBC, and partial ReadyToRun consumption. Add publish configuration, schema and compiler regressions, browser round trips, and usage documentation. Co-authored-by: Copilot <[email protected]>
Preserve legacy interpreter profiling outside single-threaded Browser, use per-method schema allocation chains, and handle sparse flow inference conservatively when exception exits are not measurable. Include the pending main merge and all local PGO fixes. Co-authored-by: Copilot <[email protected]>
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
Tagging @dotnet/jit-contrib for JIT-EE GUID update |
|
Tagging subscribers to this area: @dotnet/crossgen-contrib |
|
Azure Pipelines: Successfully started running 6 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Require exactly one method with counter data rather than one method in the entire MIBC. Rundown-only method records are expected in published application traces and do not indicate instrumentation filter leakage. Preserve the exact invocation count, schema kind, and IL offset checks. Co-authored-by: Copilot <[email protected]>
Use shared effective settings for block and edge probes and honor minimal prejit profiling. Read counter width on Wasm32 and inherit it in inlinees, preserving the required 64-bit R2R layout. Keep measured input when the compiler cannot write synthesized counts through R2R imports. Cover the configuration paths in Wasm compiler tests. Co-authored-by: Copilot <[email protected]>
Reuse the standard integer histogram probe for Memmove and SequenceEqual lengths. Export filled samples alongside sparse edge counts so existing EventPipe-to-MIBC tooling can carry both in the same profile. Cover the value-probe toggle and verify exact samples in the Blazor producer/consumer roundtrip. Co-authored-by: Copilot <[email protected]>
Report an actionable Crossgen2 error instead of silently forcing 64-bit counters when Wasm R2R instrumentation is enabled and the effective JitCollect64BitCounts override is zero. Co-authored-by: Copilot <[email protected]>
Report explicit interlocked, scalable, or multi-slot padding requests instead of silently using direct single-slot counters. Leave the supported overrides and uninstrumented compilations unchanged. Co-authored-by: Copilot <[email protected]>
|
@AndyAyersMS, Browser/CoreCLR R2R now collects ordinary sparse-edge counts and We kept one direct 64-bit counter per edge for single-threaded Browser R2R. |
Co-authored-by: Copilot <[email protected]>
Initialize the JIT's 64-bit count option on 32-bit non-Wasm targets, treat whitespace-only Wasm PGO filters as disabled in Crossgen2 and the SDK, and keep flush-time instrumentation roots from overriding time windows already applied to observed R2R or JIT method events. Co-authored-by: Copilot <[email protected]>
AndyAyersMS
left a comment
There was a problem hiding this comment.
Just a few nits on the JIT side...
Crossgen2 already applies canonical profiles to exact generic inlinees, so the extra lookup is unnecessary. Co-authored-by: Copilot <[email protected]>
Log and skip incompatible counters for the affected method only. Capture method identities independently of counter export, and cover mixed ReadyToRun and interpreter profiling in Chrome. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Share address generation between JIT and R2R probes, and mark the resolved R2R import-cell pointer invariant. Inherit the root counter width for all inlinees. Rename the internal R2R instrumentation filter without changing the Browser SDK property. Remove raw counter-option validation while keeping the supported R2R probe mode and retained-IL requirement. Co-authored-by: Copilot <[email protected]>
Collect cast type histograms in Browser CoreCLR ReadyToRun and export them through the existing EventPipe and MIBC path. Treat unreferenceable types as unknown so speculative guards cannot prevent R2R compilation. Wire PublishReadyToRunPgoInstrumentation to the Crossgen2 --pgo-instrumentation switch. Preserve all original IL in instrumented images without validating raw JIT options. Co-authored-by: Copilot <[email protected]>
Drive instrumentation through CORJIT_FLAG_BBINSTR without rewriting JIT options. Preserve the composite-only IL stripping diagnostic before retaining IL in instrumented images. Co-authored-by: Copilot <[email protected]>
|
|
||
| const bool profileCast = (JitConfig.JitClassProfiling() > 0) && impIsCastHelperEligibleForClassProbe(call) && | ||
| (call->gtHandleHistogramProfileCandidateInfo != nullptr); | ||
| if (IsAot()) |
There was a problem hiding this comment.
Is there some reason we don't enable class profiles for R2R?
I get that we want minimal profiling, and maybe why we want 64 bit counts, but beyond that I don't understand why we are limiting and modifying the data we can collect.
I'd prefer if we mostly collected the same data as we do elsewhere. If we are going to light up bespoke profiling for some apps it may actually provide a nice performance boost by lighting up meaningful GDVs.
Summary
Enable opt-in PGO collection from published Browser/CoreCLR ReadyToRun applications and consume the resulting MIBC in a subsequent optimized, partial ReadyToRun publish.
Use ordinary R2R sparse-edge counts, integer value histograms, and cast input-type histograms, plus counter-free interpreter method discovery. Interpreter presence helps select additional bodies for the next compilation; it does not fabricate invocation counts or internal branch weights.
Design
EdgeLongCountrecords and existing profile-incorporation semantics; intrinsic expansion does not create a separate callee-invocation profile.MemmoveandSequenceEquallengths. Export sampled integers and their histogram counts alongside edges in the same EventPipe trace and MIBC, without changing the consumer or the MIBC format.isinstandcastclasssites using the existing JIT class-profile helper and type-histogram format. Crossgen2 treats sampled types it cannot reference as unknown, so a speculative guard does not prevent an otherwise compilable Wasm method from getting R2R code.PgoInstrumentationSchemasR2R section andPgoInstrumentationDatafixup. Deterministic, deduplicated schemas preserve kinds, IL keys, counts and aligned offsets. The R2R format is 34.2, with the schema section at 129.dotnet-pgo create-mibc --include-interpreted-rundownto select metadata-backed interpreter code ranges from method-load/rundown events. Preserve exact/canonical generic identities and existing instrumentation data; exclude dynamic helpers and methods without usable IL bodies.MethodDetailsneeded to resolve uninstrumented methods. This capture-state enumeration adds no interpreter probes or per-call counters.Integration and scope
PublishReadyToRunPgoInstrumentation=allor a MethodSet filter selects application/framework R2R instrumentation at publish time, independently of cooperative CPU sampling.--codegenopt:JitProfileValues=0and--codegenopt:JitProfileCasts=0disable their respective probes without disabling edges.--pgo-instrumentationoption. It selects single-threaded Browser/CoreCLR instrumentation and preserves all original IL, including for methods outside the filter, even when--strip-il-bodiesis also present. Without the switch, IL stripping is unchanged. Crossgen2 does not inspect raw--codegenoptvalues to validate instrumentation.InterpPGO/InterpPGOMethodsfacility unchanged from the merged-main baseline. This workflow does not enable it or forward the instrumentation filter to the runtime. LeaveDOTNET_InterpPGOoff for normal R2R training; interpreter discovery needs no counters.collectPgoTrace(), convert with the interpreter-rundown option, then publish withPublishReadyToRunPgoFilesand producer instrumentation disabled.Validation
Local runtime/tool configuration: Browser/Wasm, CoreCLR, Debug unless noted. Browser applications cover Debug and Release.
dotnet-pgotestsDirectCallsreused one import-cell load (154 → 143 code bytes);EntryAndBackedgestayed at 106;SwitchEdgesgrew from 170 to 179. No timing claim.The three Chrome roundtrips cover Debug/non-composite/all methods, Release/composite/all methods, and Release/non-composite/filtered methods with CPU sampling. They verify the exact
SequenceEqualsamples4, 4, 4, 8, 8, sparse edge counts, preservation of measured profiles when adding interpreter presence roots, matching MVIDs, and execution of the partial consumer. The focused cast roundtrip and four configuration tests ran through the rebuilt SDK pack with the dedicated switch.Cast codegen evidence (not a timing result): the focused trace exported four
CastHotand oneCastColdsample. The consumer bypasses the cast helper for the hot type and keeps a fallback; the method grew from 65 to 139 Wasm code bytes. The broad Debug Blazor trace exported 137 cast histograms across 102 methods, including twostring-dominated sites consumed inRenderTreeBuilder.AddAttribute. No wall-clock speedup was measured.The zero-counter case prepares the target before tracing and discovers it without
InterpPGO, instrumentation data or invented CPU-sample weights. Separate cases retain the existing Debug/Release interpreter-counter behavior.Exact local build and test commands
Run from the repository root in PowerShell. The build and test commands below passed; the table distinguishes the earlier validation from the latest runs.
No full compiler-suite rerun, Mono/WASI/multithread validation, or application-speedup claim is included. Normal optimization can reclassify incorporated measured profiles as synthesized; the tests retain exact numeric checks rather than requiring a final source label to remain Static.
Tracking: #130521. Its broader interpreter/exception-profile scope is not claimed complete here. The Wasm direct-call readiness fix has an independent repro in #138199.
Note
This PR description was generated with GitHub Copilot assistance.