You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bump emsdk to >= 6.0.10 to pick up memory.copy-based memmove (overlapping Span.CopyTo is 4-5x slower on CoreCLR wasm) #136012
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
dotnet-policy-service commentedon Oct 17, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Oct 17, 2026
Tagging subscribers to this area: @steveisok, @vitek-karas
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Oct 17, 2026
Tagging subscribers to this area: @dotnet/area-system-memory
See info in area-owners.md if you want to be subscribed.
lewing commentedon Oct 17, 2026
@akoeplinger we have a good reason now :)
lewing commentedon Oct 18, 2026
the workaround in #136013 should be removed when this is completed
Use memory.copy for the memmove QCall on browser-wasm (#136013)