WASM: defer eager Numba gufunc/jit compilation to first use (#930) - #943
WASM: defer eager Numba gufunc/jit compilation to first use (#930)#943kp992 wants to merge 1 commit into
Conversation
|
Thanks @kp992. Now that #938 is merged, could you rebase this onto Two more things. #930 asks for a before/after warm-cache |
7ae4be8 to
8a7da64
Compare
Four guvectorize callables compiled at import time are now compiled lazily on first call: _probvec_parallel, _probvec_cpu, _sample_without_replacement (_ints_arr_to_bits). Gufuncs are replaced by thin Python wrapper functions that create the underlying ufunc on first invocation and cache it in a module-level sentinel. _probvec_cpu keeps the same name so the game_theory/random.py import is unchanged. Fixes QuantEcon#930, part of QuantEcon#925.
8a7da64 to
97325b6
Compare
Closes #930, part of #925.
What
Four guvectorize callables compiled at
import quantecontime are now compiled lazily on first call:_probvec_parallelrandom/utilities.py_probvec_cpurandom/utilities.py_sample_without_replacementrandom/utilities.py@guvectorizedecorator → lazy wrapper_ints_arr_to_bitsgame_theory/vertex_enumeration.pyHow
Gufuncs are replaced by thin Python wrapper functions that create the underlying ufunc on first call and cache it in a module-level sentinel.
_probvec_cpukeeps the same name so thegame_theory/random.pyimport is unchanged.Why this matters for WASM
On native CPython, eager compilation costs milliseconds. In a JupyterLite/WASM kernel, each compile is a full LLVM optimise + WASM object emit + in-process LLD link. The emscripten-forge Numba patches also force-disable
cache=Truefor@guvectorize, so the four gufunc compiles were paid on every session on the critical import path of every notebook.Public API
No change.
qe.random.probvec(..., parallel=...),qe.random.sample_without_replacement(...), andqe.game_theory.vertex_enumeration(...)are unaffected.