gristlabs / grist-static

Showing Grist spreadsheets on a static website, without a special backend.
https://gristlabs.github.io/grist-static/
Apache License 2.0
82 stars 0 forks source link

Upgrade to Pyodide 0.23.4 (with Python 3.11) and compile dependencies #19

Closed alexmojaki closed 1 year ago

alexmojaki commented 1 year ago

Goes with https://github.com/gristlabs/grist-core/pull/603

core/sandbox/pyodide/build_packages.sh now runs pyodide py-compile to compile .py files inside wheels to .pyc files which should load faster.

The webworker loads pyodide itself from https://cdn.jsdelivr.net/pyodide/v0.23.4/pyc/pyodide.js, where the /pyc/ has a similar meaning for the Python standard library. If we want to avoid using this CDN and continue serving pyodide ourselves, I don't know yet what's required to do this manually, i.e. to serve the compiled standard library.

Currently, the wheel containing grist's source code is not compiled.

core/sandbox/pyodide/packages.js now writes a file called sandbox/pyodide/package_filenames.json next to it. A copy of that file lives next to webworker.js which imports it, which is slightly less weird than the previous hardcoded list. Using a symlink doesn't work (I'm not 100% sure that's not solvable though) and I haven't yet given serious thought to automating the copying.

Since the compiled wheels aren't pushed to S3 yet, currently make requirements will download the old (now incorrect) wheels. But build_packages.sh removes the grist wheel, so you have to do a bit of an awkward dance at the moment to get everything working.

My next plan is to carefully test the difference in performance this makes. Hopefully it doesn't make things worse.

alexmojaki commented 1 year ago

Here's my analysis of the difference in performance.

paulfitz commented 1 year ago

Timing change looks great! Thanks for the breakdown. A nice side-effect of this work may be a speed up for some situations in the desktop app also, where the default sandbox is pyodide (run from node).