Visitar URL original
[browser][CoreCLR] Collect ReadyToRun PGO with indexed schemas by pavelsavara · Pull Request #137502 · dotnet/runtime · GitHub
Skip to content

[browser][CoreCLR] Collect ReadyToRun PGO with indexed schemas - #137502

Draft
pavelsavara wants to merge 2 commits into
mainfrom
pavelsavara/browser-coreclr-r2r-pgo-schema-table
Draft

pavelsavara wants to merge 2 commits into
mainfrom
pavelsavara/browser-coreclr-r2r-pgo-schema-table

Conversation

@pavelsavara

Copy link
Copy Markdown
Member

Summary

Enable opt-in PGO collection from published Browser/CoreCLR ReadyToRun applications and consume the resulting MIBC in a subsequent optimized, partial ReadyToRun publish.

Design

  • Emit 64-bit IL-backed basic-block counters through the normal JIT instrumentation phases, including inlinees. Preserve original pre-import IL block identities rather than instrumenting synthetic compiler blocks.
  • Preserve explicit invocation-only records for expanded intrinsics and coarse interpreter fallback. Intrinsic expansion leaves an IR marker that is materialized during normal instrumentation; invocation contributions remain distinct from measured body-block data.
  • Add a dedicated PgoInstrumentationSchemas ReadyToRun section and an indexed PgoInstrumentationData fixup. Deterministic, deduplicated schemas describe instrumentation kinds, IL offsets, counts, and aligned byte offsets into counter storage. The ReadyToRun format becomes 34.1.
  • Resolve each import cell to a counter allocation base and emit direct, unsynchronized 64-bit load/add/store probes at schema-defined offsets. Exact layouts share allocations; incompatible live layouts retain separate storage.
  • Aggregate compatible layouts per logical method when exporting through the existing EventPipe PGO pipeline. Validate schema and IL identity, retain distinct invocation contributions, and avoid replacing storage referenced by generated code.
  • Extend profile tooling and consumption to preserve these records, resolve canonical generic profiles, reconstruct uniquely determined block flows before heuristic repair, and combine omitted-body invocation contributions without treating them as measured branch counts.

Integration and scope

  • Forward WasmPgoInstrumentation=all or a MethodSet filter through application and framework ReadyToRun publishing, independently of CPU sampling. Recompile framework images when instrumentation changes and invalidate the corresponding incremental stamps.
  • Use DOTNET_WasmPgoInstrumentation for ordinary interpreter collection through the same profiling infrastructure.
  • Support single-threaded Browser/CoreCLR publishing with diagnostics enabled and original IL retained. Reject unsupported configurations explicitly.
  • Keep allocation and EventPipe export outside the per-block hot path. This scope does not add edge probes, type/value histograms, or precise exception-flow profiling.
  • Canonicalize body-only readiness imports so eager activation does not retain an exact constrained owner and bind dependent assemblies prematurely.
  • Add schema/layout, compiler, profile-tooling, and browser round-trip regressions, and document configuration and limitations.

Tracking: #130521.

Repository migration

Replaces dotnet/runtime#137491 so further work can use an upstream branch instead of a personal fork. The original PR retains its review discussion and historical validation details.

Upstream branch: pavelsavara/browser-coreclr-r2r-pgo-schema-table. Copied commit: 06fa85f1de97d2fb9d49281677436b6387aba9e0.

The copied commit also includes the pending main merge and all local PGO fixes: legacy interpreter profiling outside single-threaded Browser is preserved, allocation lookup uses per-method schema chains, and sparse flow inference is conservative about unmeasured exception exits. Related regression tests and documentation are included.

Current validation: builds and tests were explicitly skipped at the user's request. The new merge and fixes have not been validated by this migration session.

Note

This PR description was generated with GitHub Copilot assistance.

pavelsavara and others added 2 commits November 13, 2026 11:13
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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
@pavelsavara pavelsavara added this to the 12.0.0 milestone Nov 13, 2026
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-ReadyToRun labels Nov 13, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging @dotnet/jit-contrib for JIT-EE GUID update

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.

@azure-pipelines

Copy link
Copy Markdown
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.

This branch has not been deployed

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

Labels

arch-wasm WebAssembly architecture area-ReadyToRun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant