Skip to content

Bump emsdk to >= 6.0.10 to pick up memory.copy-based memmove (overlapping Span.CopyTo is 4-5x slower on CoreCLR wasm) #136012

Open

Description

@lewing

Problem

eng/Versions.props pins EmsdkVersion to 6.0.2. In that emscripten, memmove is musl's memmove.c: only non-overlapping copies are forwarded to memcpy (which uses memory.copy for n >= 512); overlapping copies always run a scalar word/byte loop, regardless of -mbulk-memory.

On CoreCLR wasm, SpanHelpers.Memmove sends overlapping buffers to the memmove QCall, which binds directly to the libc symbol (DllImportEntry(memmove) in src/coreclr/vm/qcallentrypoints.cpp). This shows up in the Mono interpreter vs CoreCLR composite R2R comparison (build 20261006.3), where System.Memory.Span<Char>.CopyToOverlap(Size: 3000) is ~20x slower on CoreCLR and Span<Byte>.CopyToOverlap(Size: 3000) ~13.6x slower (Mono's jiterpreter inlines memory.copy).

Local repro (corerun on node, Release browser-wasm, overlapping CopyTo, ns per call):

Case libc memmove memory.copy wrapper
char, 3000 elements ~2800-2900 ~650-800
byte, 3000 elements ~1000-1100 ~175-220

Upstream fix

emscripten-core/emscripten#27654 ("[libc] Always use __builtin_wasm_memory_copy in memmove", merged 2026-09-03) replaces the musl implementation with memory.copy; the PR reports 16-33x speedups for overlapping copies across V8, SpiderMonkey and JavaScriptCore. By tag comparison, the commit is included in 6.0.10 and later and is not in 6.0.9.

Proposal

  • Bump the emsdk (dotnet/emsdk packages and EmsdkVersion) to >= 6.0.10.
  • Once bumped, remove the browser-only QCall_memmove wrapper (carrying a TODO referencing the upstream PR) that works around this in the interim.

Notes

  • wasi-sdk 34.0 is not affected: its memmove already has a memory.copy path (BULK_MEMORY_THRESHOLD) for n > 32.
  • Remaining plain-libc memmove callers in the native runtime (interpreter arg/local moves in interpexec.cpp, GC finalization queues, utilcode collections) would also benefit from the bump; GC-ref moves use their own pointer-wide loops by design.

Note

This issue was drafted with AI assistance (GitHub Copilot) on behalf of @lewing.

Activity

  1. added
    untriaged
    on Oct 17, 2026
  2. dotnet-policy-service commented on Oct 17, 2026

    @dotnet-policy-service
    Contributor

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

  3. added
    os-browser
    and removed on Oct 17, 2026
  4. dotnet-policy-service commented on Oct 17, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @steveisok, @vitek-karas
    See info in area-owners.md if you want to be subscribed.

  5. dotnet-policy-service commented on Oct 17, 2026

    @dotnet-policy-service
    Contributor

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

  6. lewing commented on Oct 17, 2026

    @lewing
    MemberAuthor

    @akoeplinger we have a good reason now :)

  7. added this to the 12.0.0 milestone on Oct 18, 2026
  8. removed
    untriaged
    on Oct 18, 2026
  9. lewing commented on Oct 18, 2026

    @lewing
    MemberAuthor

    the workaround in #136013 should be removed when this is completed

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

Metadata

Metadata

Labels

arch-wasmarea-System.Memoryos-browser

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions