feat: add Web Workers for parallel WASM proving#81
Merged
Conversation
Add WasmWorkerPool backed by Web Workers + SharedArrayBuffer, enabling multi-threaded proving in the browser using the same Chase-Lev work-stealing pool as native. Key changes: - WasmWorkerPool: aliases NativeThreadPool methods, adds workerEntry() for JS-spawned workers. Three-way ThreadPool selection: WasmWorkerPool (atomics) / WasmThreadPoolStub (no atomics) / NativeThreadPool (native) - WasmFutex: direct memory.atomic.wait32/notify intrinsics bypassing std.Thread.Futex (which requires single_threaded=false, incompatible with std.heap.wasm_allocator) - DequeIdx: i32 on wasm32 (atomics limited to 32-bit operands) - Build: shared_memory + import_memory flags, TLS exports (__tls_base/__tls_size/__wasm_init_tls) for per-worker TLS - zolt_pool single_threaded=false for atomics builds so threadlocal uses __tls_base (not a fixed shared address) - C API: zolt_thread_pool_create_wasm, zolt_thread_pool_ptr, zolt_worker_entry - Browser demo: prover worker (non-blocking UI), compute workers, two-phase init, COOP/COEP headers for SharedArrayBuffer Build: zig build -Dtarget=wasm32-freestanding \ -Dcpu=generic+atomics+bulk_memory -Doptimize=ReleaseFast Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add WasmWorkerPool backed by Web Workers + SharedArrayBuffer, enabling multi-threaded proving in the browser using the same Chase-Lev work-stealing pool as native.
Key changes:
Build: zig build -Dtarget=wasm32-freestanding
-Dcpu=generic+atomics+bulk_memory -Doptimize=ReleaseFast