Skip to content

Enable validated async microbenchmarks on WASM - #5325

Merged
lewing merged 1 commit into
mainfrom
lewing-enable-wasm-async-benchmarks
Sep 28, 2026
Merged

lewing merged 1 commit into
mainfrom
lewing-enable-wasm-async-benchmarks

Conversation

@lewing

@lewing lewing commented Sep 28, 2026

Copy link
Copy Markdown
Member

WASM microbenchmark runs currently skip every benchmark that returns Task/ValueTask. NoWasmValidator enforced this by requiring every such benchmark to carry NoWASM. The pinned BenchmarkDotNet awaits async workloads, so returning an awaitable no longer needs to exclude a benchmark from WASM.

Changes

  • Remove NoWasmValidator and its registration in Program.cs.
  • Remove NoWASM from:
    • Perf_AsyncMethods (class)
    • ValueTaskPerfTest (class)
    • MemoryStreamTests.CopyToAsync
    • MemoryStreamChunkedTests.ReadAsyncMemory, WriteAsyncMemory, CopyToAsyncWithBufferSize
  • Other async benchmarks keep their explicit NoWASM tags, e.g. Perf_Pipe and anything that relies on thread-pool concurrency.
  • Add harness tests that check the enabled selection and the Perf_Pipe exclusion.
  • Document the policy in docs/benchmarking-workflow-dotnet-runtime.md.

Validation

Local runs (scripts/benchmarks_ci.py --wasm, 1 iteration each) with SDK 11.0.100-rc.1.26425.128:

  • Mono WASM on Node: all enabled cases ran.
  • CoreCLR WASM on V8 (--experimental-wasm-exnref): all enabled cases ran. This includes the ones that really yield: Yield, SingleYieldMethodInvocation, CreateAndAwait_FromYieldingAsyncMethod, CreateAndAwait_FromDelayedTCS.
  • Harness tests pass.

Trade-off

Without the validator, any new async benchmark runs on WASM unless it is explicitly tagged NoWASM. Benchmarks that block synchronously or need multiple threads must be tagged by hand.

Local tip: Mono and CoreCLR WASM runs share artifacts/obj/BenchmarkDotNet.Autogenerated/Release/fx/. If you switch flavors on the same checkout, delete that folder first. Otherwise a stale Mono dotnet.native.js can end up in the CoreCLR publish and fail with dotnetInitializeModule is not a function.

Remove NoWasmValidator, which required every Task/ValueTask benchmark to be
tagged NoWASM. BenchmarkDotNet now awaits async workloads, so returning an
awaitable is no longer a reason to exclude a benchmark from WASM.

Enable Perf_AsyncMethods, ValueTaskPerfTest, MemoryStreamTests.CopyToAsync and
the MemoryStreamChunkedTests async benchmarks. Validated on Mono WASM (Node)
and CoreCLR WASM (V8). Other async benchmarks keep their NoWASM tags.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 28, 2026 19:55
@lewing
lewing marked this pull request as ready for review September 28, 2026 20:35

@LoopedBard3 LoopedBard3 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for the update!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@lewing
lewing enabled auto-merge (squash) September 28, 2026 21:20
@lewing
lewing merged commit eb06bc3 into main Sep 28, 2026
79 of 80 checks passed
@lewing
lewing deleted the lewing-enable-wasm-async-benchmarks branch September 28, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants