Commit 3df9a49
fix(wasm): drop pthreads — fixes UI hang during prefill and generation (#32)
pthreads + ASYNCIFY conflict: emscripten_sleep() on the main thread
doesn't yield properly when pthreads are active (Atomics.wait-based
scheduling interferes with ASYNCIFY's stack unwinding). Result: UI
hangs during both prefill and generation despite yield calls.
Fix: remove -pthread and PTHREAD_POOL_SIZE. Keep ASYNCIFY + SIMD128
+ relaxed-simd + O3 + LTO. The emscripten_sleep(0) calls in both
prefill (every 2 tokens) and generation (every 4 tokens) now work
correctly, keeping the browser responsive.
quant.h's matmul still uses pthread_create internally, but without
-pthread they become no-ops in Emscripten — single-threaded matmul
with SIMD vectorization.
Binary: 384K → 320K (-17%, no pthread runtime).
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 3fdbaf6 commit 3df9a49
3 files changed
Lines changed: 6 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | | - | |
28 | | - | |
29 | 26 | | |
| 27 | + | |
| 28 | + | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
| 33 | + | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | | - | |
42 | | - | |
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
0 commit comments