feat(wasm,3d-viewer): run upstream multi-threaded CPU raytracer
Bumps the kicad submodule to the threading revert (the 3D-viewer raytracer's WASM single-threaded #ifdef fallbacks + the bs_thread_pool inline shim are gone; those four files are now byte-identical to upstream KiCad). Links wasm/shims/nanosleep_yield.c into every app (mirrors the gl_ffp_stub pattern): the now-upstream raw-thread raytracer joins via a main-thread sleep_for busy-wait, and this shim makes that nanosleep Asyncify-yield to the JS event loop instead of deadlocking on on-demand pthread-Worker creation. Its EM_ASYNC_JS yield is already covered by env.__asyncjs__* in asyncify-imports.txt. This is what lets upstream's multi-threaded code run on WASM under native-EH. Also documents isolated-worktree + submodule-branch creation in the README. Result: ~11x faster 3D raytrace (21.3s -> 1.9s, 16 threads), pixel-correct render, full kicad e2e green (63 passed / 0 failed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3628a090dd
commit
71807db734
3 changed files with 49 additions and 2 deletions
38
README.md
38
README.md
|
|
@ -92,6 +92,44 @@ Output: `output/pcbnew.js`, `output/pcbnew.wasm`
|
|||
|
||||
See [docs/build.md](docs/build.md) for detailed build documentation.
|
||||
|
||||
#### Creating an isolated worktree (with submodule branches)
|
||||
|
||||
For an experiment or feature you can work in a disposable git worktree so the
|
||||
main checkout stays pristine. This repo has four submodules
|
||||
(`kicad`, `wxwidgets`, `binaryen`, `web/pcbjam-shared`); a new worktree starts
|
||||
with them empty, so initialize and branch each one:
|
||||
|
||||
```bash
|
||||
# 1. Create the worktree on a new branch (off main), at a sibling path
|
||||
git worktree add -b experiment/my-thing ../kicad-wasm-my-thing main
|
||||
|
||||
# 2. Check out the submodules INSIDE the worktree (working trees only;
|
||||
# git objects are shared with the main checkout)
|
||||
cd ../kicad-wasm-my-thing
|
||||
git submodule update --init kicad wxwidgets binaryen web/pcbjam-shared
|
||||
|
||||
# 3. Create a matching branch in each submodule (they start at detached HEAD)
|
||||
git checkout -b experiment/my-thing # root already on it via -b above
|
||||
for sm in kicad wxwidgets binaryen web/pcbjam-shared; do
|
||||
git -C "$sm" checkout -b experiment/my-thing
|
||||
done
|
||||
```
|
||||
|
||||
Then build from inside the worktree. Use an **isolated** Docker project — do NOT
|
||||
set `COMPOSE_PROJECT_NAME` to another branch's project (e.g. `kicad-wasm-main`),
|
||||
which can collide with other workflows; `docker/build.sh` auto-derives an isolated
|
||||
project name from the worktree branch. The first build provisions deps
|
||||
(wxWidgets + OCC) from scratch. To keep the machine responsive / bound wasm-opt
|
||||
RAM, cap parallelism and skip the slow release optimization:
|
||||
|
||||
```bash
|
||||
KICAD_DOCKER_CPUS=4 BINARYEN_CORES=4 BINARYEN_OPT_LEVEL=-O1 \
|
||||
./docker/build.sh pcbnew -j 4
|
||||
```
|
||||
|
||||
Tear down afterward with `git worktree remove ../kicad-wasm-my-thing` (and
|
||||
`docker compose -p <project> down -v` to drop the isolated volumes).
|
||||
|
||||
#### Fresh worktree provisioning
|
||||
|
||||
Some test artifacts are gitignored and are NOT produced by the build pipeline,
|
||||
|
|
|
|||
Loading…
Reference in a new issue