Monday, April 18, 2022

Python on WebAssembly: How does it perform? (Part I)

Intrigued by Christian Heimes's "web browser journey" of Python 3.11 and Lin Clark's talks about WASI, I am curious about the feasibility of running performance-aware Python apps inside WebAssembly standalone (non-web) runtime(s).

So how does Python perform inside WebAssembly?

Here is a roadmap to produce my own answers:

0. Placing code and recipes generated during this research at github.com/gatopeich/python-wasm-bench, so results can be reproduced easily and expanded...

1. Compare CPython performance inside Wasm with the native version

  • Preliminary result: Wasmer/WAPM Python 3.6 package is 3~4 times slower than Docker equivalent. My measures here match the expectations set by Chris Heimes. WAPM is the easiest way to have a standalone wasm Python interpreter, however the package itself is a bit outdated.

2. Learn about performance profiling in WASM/WASI: will I be able to find any obvious bottleneck?

  • In particular: how is the core Python "dict" implementation working there? I am a bit skeptical sure how highly optimized state of the art code will suffer in the translation to four-type WASM code.

3. Could it be helped with some native implementations via WASI? Will it be worth it or required at all? Will there be just another way to optimize things for the WASM runtime and JIT?


(Note to self: move to a blog engine more suitable for coding matters)

 

No comments:

Post a Comment