Repository navigation
[Wasm] Experimentally disable loop cloning and unrolling - #136640
adamperlin wants to merge 1 commit into
Conversation
Experiment with the Wasm code-size and loop-throughput tradeoff; leave other targets unchanged. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1c35665e-3fd9-4953-99e6-1beb765e7732
|
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. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
I think loop clonning is very important for bound check removal, I doubt only a handful benchmarks are affected by it. Perhaps, we should make it more conservative for optimize-for-size instead? cc @AndyAyersMS Loop unrolling presumed to be a rare thing. |
That makes a lot of sense. I'll switch this to draft as this was mostly intended just as an experiment to see what the size impact is. |
Experimentally skip loop cloning and unrolling for
TARGET_WASMin all build configurations; other targets are unchanged.Tradeoff: the 15 selected loop benchmarks were 1.69% slower (unweighted geometric mean), including
SameIndex2+12.20% and LLoops +8.97%, for these size reductions:Full benchmark numbers and measurement setup
Positive time change means slower with both optimizations disabled. Times are per operation.
ArrayDeAbstraction.foreach_static_array_via_interfaceArrayDeAbstraction.foreach_member_arrayArrayDeAbstraction.sum_static_array_via_localBenchstone.BenchF.Adams.TestBenchstone.BenchF.LLoops.TestLayout.SearchLoops.LoopReturnLayout.SearchLoops.LoopGotoSpan.IndexerBench.CoveredIndex2Span.IndexerBench.WriteViaIndexer2Span.IndexerBench.RefSpan.IndexerBench.Indexer1Span.IndexerBench.Indexer4Span.IndexerBench.SameIndex1Span.IndexerBench.SameIndex2Span.IndexerBench.KnownSizeCtor2Checked Wasm JITs at
35d5d14d206; unchanged benchmark sources from dotnet/performance8588cdaa, linked into a focused BenchmarkDotNet harness. Release IL, per-assembly CoreCLR/Wasm ReadyToRun, Node.js 26.13.0; two launches, three warmups and 15 measured iterations per launch; span length 1,024. Both variants used the same private SDK overlay/native runtime, not a fully rebuilt SDK/workload cohort. Shared Hyper-V VM; small timing differences may be noise.SameIndex2retains an in-loop bounds check without cloning (372 to 266 code bytes).KnownSizeCtor2's helper had identical single-method codegen, so its measured speedup is not a direct codegen improvement. Cloning and unrolling were measured together.SuperPMI compared 90,210/91,104 library contexts and 28,200/29,068 cached CoreLib contexts; missing recorded data excluded 894 and 868 respectively, with no other compilation failures. Total modeled PerfScore increased 0.401% and 0.979%; this is not measured execution time.
Validation:
.\build.cmd clr.wasmjit -rc Checkedpassed; all 15 benchmark cases completed on both variants; identical-JIT SuperPMI control had no diffs in the 969 changed library contexts.Note
PR description and analysis generated with GitHub Copilot.