Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 6 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @dotnet/crossgen-contrib |
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
|
I'm exploring tooling changes against this prototype. |
| } | ||
| metadata[8] = branchHint == WasmBranchHint::LikelyTrue ? 1 : 0; | ||
|
|
||
| JitMetadata::report(m_compiler, JitMetadata::WasmBranchHint, metadata, sizeof(metadata)); |
There was a problem hiding this comment.
We don't want to call report here, it will get called automatically when the jit is done with the method. Instead, increment the metric.
| instrDesc* prevId = nullptr; | ||
| #endif // defined(DEBUG) && defined(TARGET_ARM64) | ||
|
|
||
| #ifdef TARGET_WASM |
There was a problem hiding this comment.
Omit this (see below).
If you want to know what % of branches got hinted it will take more work.
| assert(trueTarget != block->Next()); | ||
|
|
||
| WasmBranchHint branchHint = WasmBranchHint::None; | ||
| bool const hasStaticProfile = |
There was a problem hiding this comment.
I would just call fgHaveProfileWeights here and not worry about the source or quantity.
| WasmBranchHint branchHint = WasmBranchHint::None; | ||
| bool const hasStaticProfile = | ||
| (m_compiler->fgPgoSource == ICorJitInfo::PgoSource::Static) && m_compiler->fgHaveSufficientProfileWeights(); | ||
| if (hasStaticProfile || (JitConfig.JitWasmBranchHintStress() != 0)) |
There was a problem hiding this comment.
Instead of forcing on hints then you could force them off here.
Summary
Emit the standardized WebAssembly
metadata.code.branch_hintcustom section from CoreCLR ReadyToRun compilation when static PGO identifies strongly biased conditional branches.This is an experimental implementation for #133794. Engines that do not consume branch hints safely ignore the custom section.
Design
br_ifinstruction descriptor.metadata.code.branch_hintcustom section immediately before the code section.A
JitWasmBranchHintStressswitch permits deterministic tests using synthesized profile weights without changing production gating.Validation
./build.sh clrPATH=/opt/homebrew/bin:$PATH ./build.sh -os browser -c Debug -subset clr+libspython3 src/coreclr/scripts/jitformat.py -r <runtime> -o osx -a arm64 -b Checked --verbose --fix --projects dllILCompiler.ReadyToRun.Tests: 75 passed, 37 skipped, 0 failediforbr_ifopcode.Size impact
For the test module, identical synthesized profile input produced:
The custom section and hints add 32 bytes in this sample.
Follow-up measurements
This draft establishes correct metadata generation. Before considering it ready to merge, it needs end-to-end measurements on Wasm engines that consume branch hints, including representative application startup/steady-state results, engine compilation time, generated native-code size, and broader R2R image-size impact.
Note
This pull request description was drafted with GitHub Copilot.