Repository navigation
Wasm spmi collect libraries - #132538
Wasm spmi collect libraries#132538AndyAyersMS wants to merge 7 commits into
Conversation
The browser/wasm crossgen2 SuperPMI collection compiled exactly one assembly, the wasm-built System.Private.CoreLib.dll, which is a very narrow slice of JIT coverage for the wasm target: one Helix partition, one MCH, and no coverage of any shared framework library. Extend it to the full browser-wasm managed assembly set, sourced from the browser-wasm CoreCLR runtime pack: - The browser_wasm_win build job now builds `clr+libs+packs` instead of `clr.corelib`, since the runtime pack layout is produced by the packs.product subset. It uploads only the runtime pack directory rather than all of artifacts/bin. - superpmi_collect_setup.py flattens the runtime pack's managed assemblies (lib/<tfm>/*.dll plus native/System.Private.CoreLib.dll, which is where CoreCLR runtime packs keep corelib) into the set to partition over. - crossgen2 has to resolve references against the target's assemblies rather than the host Core_Root, so add an explicit `-crossgen2_reference_directory` option to superpmi.py collect. The setup script stages the assemblies into the correlation payload and reports the folder name via a pipeline variable that superpmi-collect.proj turns into the new option. Host-target collections are unaffected; the option defaults to Core_Root. - The corelib-specific special cases in superpmi_collect_setup.py are replaced by conditions on cross-targeting. The collection is renamed from `corelib` to `libraries`, matching the other crossgen2 collections. Because it now shares collectionName/collectionType/osGroup/archType/buildConfig with the host-target windows-x64 libraries collection, published artifact names gain a target suffix and the job display name includes the target. The partition size becomes a template parameter (default 25 MB) so the wasm job can use a smaller value and spread its ~30 MB of assemblies over several Helix work items. Note that the rename orphans corelib.crossgen2.windows.x64.checked.mch under <jit_ee_version>/browser/x64/. Replay downloads every MCH under that prefix, so the stale file has to be deleted from the collections container by hand. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9c6bbfae-eed7-4545-8f2a-5cfb15d62df4
…ossgen2
Comment out every collection other than the browser/wasm crossgen2 one so
a test run of the new collection doesn't spend CI time on everything else,
and trim the two windows_x64 runtime build jobs to that single platform.
The four jobs left running are exactly what the wasm collection needs:
- windows_x64 checked build (build_windows_x64_checked_, the collect
job's dependsOn; supplies the checked Core_Root and the wasm JIT)
- windows_x64 release build (supplies BuildArtifacts_windows_x64_Release
for the release Core_Root)
- browser_wasm_win Release (build_browser_wasm_windows_Release_, the
runtime pack the collection compiles)
- the crossgen2/libraries browser/wasm collection itself
Revert this commit before merging.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 9c6bbfae-eed7-4545-8f2a-5cfb15d62df4
|
/azp run runtime-coreclr superpmi-collect-test |
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Enable SuperPMI cross-target crossgen2 collections (notably browser/wasm) by staging target assemblies and letting crossgen2 resolve references from a target reference directory rather than the host Core_Root.
Changes:
- Add runtime-pack staging logic in
superpmi_collect_setup.pyto flatten target managed assemblies and publish aCrossgen2ReferenceDirNamepipeline variable. - Add
-crossgen2_reference_directorytosuperpmi.pyand use it when writing thecrossgen2response file references. - Update collection/replay MSBuild + AzDO pipeline templates to consume the staged reference directory and switch wasm collection naming to
libraries.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/scripts/superpmi_collect_setup.py | Stages target runtime-pack assemblies for wasm and emits Crossgen2ReferenceDirName. |
| src/coreclr/scripts/superpmi.py | Adds -crossgen2_reference_directory and uses it for crossgen2 reference resolution. |
| src/coreclr/scripts/superpmi-replay.proj | Updates wasm replay comment to match the renamed wasm collection. |
| src/coreclr/scripts/superpmi-collect.proj | Plumbs Crossgen2ReferenceDirName into -crossgen2_reference_directory. |
| eng/pipelines/coreclr/templates/superpmi-send-to-helix.yml | Adds Crossgen2ReferenceDirName template parameter plumbing. |
| eng/pipelines/coreclr/templates/superpmi-collect-pipeline.yml | Switches wasm collection to libraries and adjusts wasm build artifacts; currently includes temporary “do not merge” edits. |
| eng/pipelines/coreclr/templates/superpmi-collect-job.yml | Adds maxPartitionSizeMB, improves display name for cross-target jobs, downloads wasm runtime pack artifact. |
| eng/pipelines/coreclr/templates/run-superpmi-collect-job.yml | Computes unique artifact names for cross-target, wires maxPartitionSizeMB and Crossgen2ReferenceDirName, updates wasm InputDirectory. |
The wasm collection only produced 82,870 method contexts. Most of the shortfall is structural: crossgen2 compiles each assembly in its own version bubble, so generic instantiations that cross an assembly boundary -- above all instantiations over CoreLib types, which is most of them -- are skipped as cross-bubble and never reach the JIT. Add a `--crossgen2_composite` option to `superpmi.py collect`. In that mode a work item's assemblies are compiled in a single crossgen2 invocation with `--composite`, and every other managed assembly in the reference set is passed as an unrooted input (`-u`). Unrooted inputs join the version bubble without being rooted, so each work item sees the whole framework as one bubble while still only rooting its own partition. Measured locally over the equivalent x64 shared framework (181 assemblies, real crossgen2 + SuperPMI collection): non-composite 93,077 contexts 1000 MB 3m20s composite 123,347 contexts 677 MB 5m31s so a third more contexts, and the merged MCH is smaller. The composite collection replays clean. The collection stays partitioned. Every partition gets the full bubble either way, and the merge step deduplicates the overlap between them, so partitioning costs redundant compilation but keeps the work parallel and keeps a single failure from losing the whole collection. One 5 MB partition measured 95s locally, so five in parallel is about the same wall time as one unpartitioned run. The per-work-item timeout goes to 4:00 for composite since each item now compiles considerably more. Two supporting helpers: - `is_managed_assembly` filters native binaries out of the unrooted set. crossgen2's unrooted-input loop loads modules without tolerating failure, and reference directories such as Core_Root contain native DLLs that match the reference globs (System.IO.Compression.Native.dll). - `get_assembly_simple_name` is used both to exclude rooted assemblies from the unrooted set and to reject a work item containing duplicate assembly simple names up front. crossgen2 keys modules by simple name and aborts on a collision; partition payloads preserve directory structure precisely because duplicate file names are expected for some collections. The non-composite path is unchanged: collecting the same assemblies without the flag produces an identical context count. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9c6bbfae-eed7-4545-8f2a-5cfb15d62df4
|
/azp run runtime-coreclr superpmi-collect-test |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Staging the runtime pack assumed exactly one target framework directory under `lib` and hard-failed otherwise, which is fragile if the pack ever grows another one. Select the highest `netX.Y` instead, comparing the version numerically so `net10.0` beats `net9.0`, and sort anything unrecognized below all of them. Staging every target framework directory is not an option: the assemblies would collide on assembly simple name, which crossgen2 rejects outright in composite mode. Missing the `lib` directory entirely is still an error, just a clearer one. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9c6bbfae-eed7-4545-8f2a-5cfb15d62df4
… wasm crossgen2" This reverts commit da0df10.
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
The comment quoted the local x64 proxy measurement taken before the collection had run in CI. Replace it with the actual result for this collection: 82,870 -> 109,684 contexts, and 177,230 collected across partitions before merge deduplication. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9c6bbfae-eed7-4545-8f2a-5cfb15d62df4
|
Now has 109,684 contexts (177,230 raw contexts pre-merge). This is crossgen2 + other BCL libs, in composite mode. @adamperlin PTAL |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
eng/pipelines/coreclr/templates/superpmi-collect-pipeline.yml:16
- This pipeline file still contains an explicit "TEMPORARY, do not merge" block and has large portions of the original platform matrix commented out. Merging this as-is would significantly reduce SuperPMI collection coverage and appears to be intentionally marked as non-mergeable.
Please revert the temporary trimming and restore the full intended build/collection matrix before merging.
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: checked
platforms:
- windows_x64
| collectionName: '' | ||
| targetOS: '' | ||
| targetArch: '' | ||
| maxPartitionSizeMB: 25 | ||
| crossgen2Composite: '' |
| # -r:<reference_dir>\System.*.dll | ||
| # -r:<reference_dir>\Microsoft.*.dll | ||
| # -r:<reference_dir>\System.Private.CoreLib.dll | ||
| # -r:<reference_dir>\netstandard.dll |
| # crossgen2 hard-fails on a native binary passed as an input, | ||
| # and reference directories such as Core_Root contain plenty. | ||
| if not is_managed_assembly(unrooted_assembly): | ||
| continue | ||
| rsp_write_handle.write("-u:" + unrooted_assembly + "\n") |
| - template: /eng/pipelines/coreclr/templates/superpmi-send-to-helix.yml | ||
| parameters: | ||
| HelixSource: '$(HelixSourcePrefix)/$(Build.Repository.Name)/$(Build.SourceBranch)' # sources must start with pr/, official/, prodcon/, or agent/ | ||
| HelixType: 'test/superpmi/$(CollectionName)/$(CollectionType)/$(Architecture)' |
There was a problem hiding this comment.
It seems that CollectionTargetSuffix should be added in HelixType because it was added in artifactName: 'SuperPMI_Collection_$(CollectionName)_$(CollectionType)$(CollectionTargetSuffix)_$(osGroup)$(osSubgroup)_$(archType)_$(buildConfig)_Attempt$(System.JobAttempt)'. Otherwise, Helix will group and track the wasm libraries/crossgen2 runs and the regular libraries runs as one thing, which mixes up results and history.
HelixType: 'test/superpmi/$(CollectionName)/$(CollectionType)$(CollectionTargetSuffix)/$(Architecture)'
| enableTelemetry: ${{ parameters.enableTelemetry }} | ||
| enablePublishBuildArtifacts: true | ||
| continueOnError: ${{ parameters.continueOnError }} | ||
| collectionType: $ {{ parameters.collectionType }} |
There was a problem hiding this comment.
| collectionType: ${{ parameters.collectionType }} |
| # uploaded under <jit_ee_version>/browser/x64/ (the wasm mch_arch override in | ||
| # superpmi.py maps target_arch=wasm to mch_arch=<host_arch>=x64). | ||
| # | ||
| # NOTE: this collection was previously named 'corelib'. Replay downloads every MCH |
There was a problem hiding this comment.
Do we need this note? This looks like a task we just need to do once this PR lands?
| # CoreLib) get compiled instead of being skipped as cross-bubble. Measured on | ||
| # this collection: 82,870 -> 109,684 contexts (+32%). | ||
| crossgen2Composite: true | ||
| # Keep the collection partitioned. Each work item roots only its own partition |
There was a problem hiding this comment.
What does "root" mean here in the context of partitions? Root Assemblies that are getting crossgen'd?
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
…5296) This is a continuation of #132538 which @AndyAyersMS opened; The only real change is addressing review feedback. The overall idea here is to run superpmi collection over composite crossgen2 compilations of library assemblies to significantly increase the number of method contexts for Wasm. ## Validation - [x] The new collection is an appropriate size and replays cleanly with a local `superpmi.py replay` - [x] The collection shows appropriate asmdiffs when run with against a JIT with **FullOpts** changes ## JIT-EE Bump This PR publishes a new JIT-EE GUID to force a new collection to be used instead of the old `corelib` collection. --------- Co-authored-by: Copilot <[email protected]> Copilot-Session: 9c6bbfae-eed7-4545-8f2a-5cfb15d62df4 Copilot-Session: cab095ec-ed42-4681-bb05-39e3b20b3aa7 Copilot-Session: ca214a40-e41a-4bf5-a3d8-f57ba9c01cf6 Copilot-Session: 68180ef1-f87f-43d6-9b86-e2e924240351
Wasm has no runtime JIT, so crossgen2 is the only way to collect browser/wasm SuperPMI contexts. Today's only wasm collection, `libraries.crossgen2` (composite, from #135296), compiles just the browser-wasm runtime pack: **89,081 contexts**. The x64 `libraries.crossgen2` collection has 284,215, mostly because its input is all of Core_Root (331 assemblies vs 181). The CoreLib partition is about the same size on both (27.2k wasm vs 28.0k x64). The other collection kinds aren't possible for wasm: `*.run` needs a runtime JIT, PMI would load the wasm32 JIT into the x64 runtime, and there's no wasm NativeAOT target. ## Changes **A. Wider `libraries` input.** The wasm collection now also compiles the portable non-framework IL at the top level of Core_Root: Roslyn, TraceEvent, FSharp.Core, Newtonsoft.Json, xunit, and the out-of-band libraries. Windows-only libraries are skipped. These are the inputs the host `libraries` collections already compile. The runtime pack is now passed to `superpmi_collect_setup.py` with a new `-target_runtime_pack_directory` argument instead of `InputDirectory`. **B. New `coreclr_tests.crossgen2` wasm collection.** crossgen2 compiles the `JIT/` tests from the AnyOS coreclr test build one assembly at a time, against the runtime pack plus one staged copy of `TestLibrary`/`XUnitWrapperLibrary`. Tests built with optimizations disabled should also add MinOpts contexts; there are only 20 today. Partitions keep each test directory together, so dependencies copied next to a test resolve through `-r:<input dir>/*.dll`. This is the closest wasm can get to the `coreclr_tests.run` collections that other platforms have. The Arm and x86 hardware intrinsics tests are excluded: on wasm they mostly compile software fallbacks, and they were most of the input (934 MB → 288 MB). `is_managed_assembly` and `get_assembly_simple_name` move from `superpmi.py` to `jitutil.py` so the setup script can use them. Host collections are unchanged. ## Validation superpmi-collect-test [build 1656858](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1656858): - **A:** wasm `libraries.crossgen2` = **221,445 contexts** (was 89,081, 2.5×); 10 partitions, 26 minutes. - **B:** wasm `coreclr_tests.crossgen2` = **207,364 contexts**; 14 partitions, all replays clean, 38 minutes. Combined wasm coverage is ~429k contexts, 4.8× today's. - The other failures in that run are outside this change: `run` collections ("No files found to merge", also failing on main's collection), `aspire` on Windows (clone hits "Filename too long"), canceled osx-arm64 jobs (also canceled on main), and one `System.Diagnostics.Process` test failure in `libraries_tests` linux-arm64. An earlier run ([build 1656419](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1656419)) lost a B partition to the 2-hour work item timeout on `JIT/Regression_3/DevDiv_255294`: 62,335 chained `if`s that hit a quadratic walk in redundant branch opts. That was fixed in the JIT by #136740, so this PR doesn't need a workaround. That run also had B compiling the Arm and x86 hardware intrinsics tests; they are now excluded (934 MB → 288 MB of input), since on wasm they mostly compile software fallbacks. Local validation: - `superpmi_collect_setup.py` dry runs for wasm `libraries`, wasm `coreclr_tests` (over the real downloaded `JIT/` tree: 14 partitions; only `HardwareIntrinsics/General*` and `*Wasm*` remain), and host `libraries` (partitions identical to before). - `superpmi.py collect --crossgen2` targeting browser/wasm with a locally built checked crossgen2, wasm JIT and collector shim produces a valid MCH. Supersedes the remaining work in #132538, which #135296 continued. > [!NOTE] > This PR description was generated with GitHub Copilot. --------- Co-authored-by: Copilot App <[email protected]>
|
Superseded by #136717 |
Extend Wasm SPMI to collect over the full BCL (crossgen2, composite mode).