v1.5.5 — warm-path perf fix: ensure_emscripten_available 940ms → ~1ms
Warm-path performance fix for ensure_emscripten_available(). The function was costing ~940 ms per call in FastLED's bash compile wasm warm-rebuild timing, dominated by two HTTPS calls to GitHub verifying the upstream SHA256 hadn't changed.
Bench (Windows, fresh install)
| Path | Before (1.5.4) | After (1.5.5) |
|---|---|---|
| Warm: done.txt < 24h + marker present | ~940 ms | ~1 ms |
| Memoized: second call same process | ~940 ms | ~0.001 ms |
Forced re-check (CLANG_TOOL_CHAIN_FORCE_MANIFEST_CHECK=1) |
~940 ms | ~210 ms |
| Cold (no done.txt) | — | unchanged |
What changed (four layered fast paths)
1. Skip GitHub manifest re-fetch when done.txt is fresh
is_emscripten_installed() makes 2 HTTPS calls every invocation to verify upstream SHA256. New _can_skip_manifest_recheck(done_path) short-circuits when done.txt is < 24 h old. Override with CLANG_TOOL_CHAIN_FORCE_MANIFEST_CHECK=1 for explicit re-check. clang-tool-chain install ... still always hits the network.
2. Marker file in _apply_wasm_ld_patch
First successful patch drops .ctc-wasm-ld-patched.v1 sidecar. Subsequent calls take one Path.exists() instead of reading ~30 MB shared.py and substring-scanning for the inline marker. Pre-1.5.5 installs detect-and-upgrade on first call.
3. Process-level memoization
set[(platform, arch)] of verified tuples. Second call in same process is a no-op. Cross-process callers (FastLED's per-build subprocess pattern) get the marker + done.txt-age paths instead.
4. Skip _verify_file_readable past 5 s race window
Three open()+read() checks that guarded a Windows filesystem-sync race in the first seconds after extraction. Once done.txt is older than 5 s the race is closed; skip. Saves ~30–100 ms.
Compatibility
- No API changes
- Backwards-compatible with pre-1.5.5 patched installs (auto-upgrades the marker on first call)
- Reinstalls wipe
install_dirwholesale, so marker + shared.py stay coherent - Memoization is per-process; cross-process behaviour unchanged
- New env var
CLANG_TOOL_CHAIN_FORCE_MANIFEST_CHECK=1for explicit re-checks
Tests
10 new unit tests + 84 broader emscripten regression tests pass. Pyright + ruff clean.
Install
pip install --upgrade clang-tool-chain🤖 Generated with Claude Code