Skip to content

[browser][coreCLR] R2R: Enable PGO instrumentation for the WASM RyuJIT #130521

Description

@pavelsavara

Enable PGO instrumentation for the WASM RyuJIT

Part of #130524.

Status: draft / issue candidate · Area: CoreCLR JIT, PGO, WASM build · Related: #130517 (interpreter PGO producer)

Goal

Bring the full dynamic-profile (PGO) subsystem online for the WebAssembly RyuJIT target, so the JIT on WASM can both produce and consume profile data at parity with the desktop runtime. This is the follow-up that removes the platform limitation #130517 works around, and it is the general enabler for profile-guided precompilation and codegen on WASM.

Because dev-loop/Debug app uses R2R images from runtime pack, this feature would only supported for publish.

Why

PGO (and tiered compilation) are currently disabled for the browser/WASM build, so the shared profile subsystem and the JIT's profiling entry points are absent or stubbed there. As long as that is the case, only a narrow interpreter-only producer (#130517) is possible, and the JIT cannot participate in profiling at all. Enabling the feature is the difference between a one-off prototype path and durable, first-class PGO support on WASM.

Direction

  • Turn on the profile feature for the WASM build so the shared profile subsystem exists and the JIT's instrumentation and consumption paths are live rather than stubbed.
  • Decouple profiling from tiered compilation on WASM. Tiered compilation is off for this target, and the existing profiling path assumes tiering eligibility. PGO must work without that assumption — either by separating the two concerns or by providing a WASM-appropriate trigger for collecting and applying profiles.
  • Validate produce-and-consume on WASM. Confirm the JIT can emit instrumented code, that counts flow into the shared representation, and that a collected profile is read back to guide optimized precompilation/codegen — the same round trip the desktop runtime supports.

Scope

In: enabling the profile feature in the WASM build configuration; reconciling profiling with the tiering-off reality on WASM; validating the JIT produce/consume round trip on WASM.

Out: interpreter-side counting (that is #130517); precompiled-code packaging and loading; profile-export transport specifics.

Success criteria

Dependencies & relationship to #130517

Open questions

  • Is profiling-without-tiered-compilation a supported and tested configuration, and what work is needed to make it one on WASM?
  • Build-size and complexity cost of enabling the feature for WASM, and whether any of it should be opt-in.
  • Any WASM-specific gaps in emitting instrumented code or in reading profiles back for codegen.

Note

This issue was drafted with GitHub Copilot assistance.

Activity

  1. added this to the Future milestone on Jul 10, 2026
  2. self-assigned this
    on Jul 10, 2026
  3. dotnet-policy-service commented on Jul 10, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  4. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Jul 10, 2026
  5. dotnet-policy-service commented on Jul 10, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  6. changed the title [-][browser][coreCLR] R2R: X2 — Enable PGO instrumentation for the WASM RyuJIT[/-] [+][browser][coreCLR] R2R: Enable PGO instrumentation for the WASM RyuJIT[/+] on Jul 10, 2026
  7. modified the milestones: Future, 12.0.0 on Jul 13, 2026
  8. pavelsavara commented on Aug 24, 2026

    @pavelsavara
    MemberAuthor

    For the EventPipe-based PGO producer, the profile records should identify methods (and their blocks) purely by IL-level identity:

    • Module MVID — via LoaderModuleID on the MethodDetails event (→ module signature)
    • Metadata token — MethodToken
    • Generic instantiation — TypeID / BulkType for generic type/method arguments
    • IL offset — per block-count record (the BasicBlockIntCount schema entry's ILOffset)

    This is exactly what the existing MethodDetails (event 72) + BulkType (15) + MethodJitInstrumentationDataVerbose (298) events already carry, and it's what dotnet-pgo uses to resolve methods against the reference assemblies (matched by MVID + token). It is engine-independent, so the interpreter producer (#130517) and the RyuJIT producer tracked here emit the same schema and are resolved identically — the only requirement is that --reference points at the assemblies whose MVIDs match the trace (on browser/wasm that's the IL-trimmed linked/*.dll, since ILLink regenerates the MVID and webcil preserves it).

    This path does not need a PerfMap. PerfMap / .r2rmap is a native-address → method map used to symbolicate CPU samples; it's a different axis from instrumentation PGO. Because block counts are keyed by MVID + token + IL offset (never by native code addresses), no native symbolication is involved in producing or consuming the .mibc. PerfMap only becomes relevant for the sample-based path (dotnet-pgo --spgo) over R2R-compiled native code, where samples are native addresses that must be mapped back to those same method tokens — but that's out of scope for instrumentation PGO.

    Note

    This comment was generated with GitHub Copilot assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIos-browserBrowser variant of arch-wasm

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions