Summary
Add ZSTDMT-style parallelism: split the input into independent jobs so both
compression and decompression can run across multiple threads, and ship a
thread-capable wasm payload (wasm-simd128-mt) so the same parallelism is
available in the browser.
Core: parallel compress + decompress via job splitting
Mirror libzstd's ZSTDMT model. The unit of parallelism is an independent
job, not a single zstd block:
So the deliverable is: a job-splitting layer (compress side) that produces a
stream whose job boundaries are independently decodable, plus a parallel driver
on both sides. Within one job/frame, decode stays sequential by construction.
wasm delivery: wasm-simd128-mt payload
A third wasm payload, built with the WebAssembly threads proposal, that runs the
parallel compress/decompress across Web Workers — shipped alongside the existing
simd and scalar payloads.
- Build with
-C target-feature=+atomics,+bulk-memory,+mutable-globals and
-Z build-std (shared-memory std).
- Bootstrap a worker pool (e.g.
wasm-bindgen-rayon): the main module hands
each worker the compiled module + shared memory.
- Runtime gate in the npm loader: select
mt only when crossOriginIsolated
is true (SharedArrayBuffer available); otherwise fall back to simd /
scalar. Document the required COOP (same-origin) + COEP
(require-corp) response headers for consumers.
- Package the third payload directory (
mt/) and extend capability detection
Dependencies
The wasm-mt payload is the browser delivery of the same job-splitting parallel
codec; the native tracks (#19, #72) provide the parallel driver this packages.
Acceptance criteria
- Job-split compression produces a valid stream whose jobs are independently
decodable; parallel compress shows a multi-core speedup, output decodes in any
compliant zstd decoder.
- Parallel decompression across independent jobs/frames shows a multi-core
speedup; single-frame decode is unchanged (documented sequential limit, not a
regression).
wasm-simd128-mt builds and loads under a cross-origin-isolated host; falls
back cleanly to simd / scalar when SharedArrayBuffer is unavailable.
- Round-trip + cross-decoder parity tests pass on all payloads.
- Consumer docs cover the COOP/COEP requirement.
Estimate
The wasm-mt payload + loader: 3d 4h (build-std + worker bootstrap + capability
detection + COOP/COEP docs + packaging + parity tests). The parallel
compress/decompress engine itself is the native tracks (#19, #72) and is
estimated there.
Summary
Add ZSTDMT-style parallelism: split the input into independent jobs so both
compression and decompression can run across multiple threads, and ship a
thread-capable wasm payload (
wasm-simd128-mt) so the same parallelism isavailable in the browser.
Core: parallel compress + decompress via job splitting
Mirror libzstd's ZSTDMT model. The unit of parallelism is an independent
job, not a single zstd block:
context/thread, concatenate the results. (Native track: feat(encoding): Rust-side rayon-based multi-threaded compression (multi-frame concat) #19 rayon
multi-frame compression.)
A single frame decodes strictly sequentially (every block depends on the
window built by the preceding blocks), so parallel decode requires the jobs
to be self-contained (concatenated independent frames, or explicit
rsyncable / window-reset boundaries). Cross-frame parallel decode + the
intra-frame block scheduling question is the native track perf(decoding): parallel block decompression for multi-block frames #72.
So the deliverable is: a job-splitting layer (compress side) that produces a
stream whose job boundaries are independently decodable, plus a parallel driver
on both sides. Within one job/frame, decode stays sequential by construction.
wasm delivery:
wasm-simd128-mtpayloadA third wasm payload, built with the WebAssembly threads proposal, that runs the
parallel compress/decompress across Web Workers — shipped alongside the existing
simdandscalarpayloads.-C target-feature=+atomics,+bulk-memory,+mutable-globalsand-Z build-std(shared-memory std).wasm-bindgen-rayon): the main module handseach worker the compiled module + shared memory.
mtonly whencrossOriginIsolatedis true (SharedArrayBuffer available); otherwise fall back to
simd/scalar. Document the required COOP (same-origin) + COEP(
require-corp) response headers for consumers.mt/) and extend capability detectionDependencies
The wasm-mt payload is the browser delivery of the same job-splitting parallel
codec; the native tracks (#19, #72) provide the parallel driver this packages.
Acceptance criteria
decodable; parallel compress shows a multi-core speedup, output decodes in any
compliant zstd decoder.
speedup; single-frame decode is unchanged (documented sequential limit, not a
regression).
wasm-simd128-mtbuilds and loads under a cross-origin-isolated host; fallsback cleanly to
simd/scalarwhen SharedArrayBuffer is unavailable.Estimate
The wasm-mt payload + loader: 3d 4h (build-std + worker bootstrap + capability
detection + COOP/COEP docs + packaging + parity tests). The parallel
compress/decompress engine itself is the native tracks (#19, #72) and is
estimated there.