sagemathinc / cowasm

CoWasm: Collaborative WebAssembly for Servers and Browsers. Built using Zig. Supports Python with extension modules, including numpy.
https://cowasm.org
BSD 3-Clause "New" or "Revised" License
491 stars 25 forks source link

idea to make initial loading in a webpage much faster (mainly for repl). #22

Closed williamstein closed 2 years ago

williamstein commented 2 years ago

Here's what is actually accessed on init:

~/python-wasm/packages/python-wasm$ npx jest dist/wasm/posix/stdlib.test.js
  console.log
    mapFlags openSync / 0 undefined

      at Object.openSync (../wasi/src/fs.ts:156:13)

  console.log
    mapFlags openSync /pybuilddir.txt 0 undefined

      at Object.openSync (../wasi/src/fs.ts:156:13)

  console.log
    mapFlags openSync /usr/lib/python3.11 0 undefined

      at Object.openSync (../wasi/src/fs.ts:156:13)

  console.log
    mapFlags openSync /usr/lib/python3.11/encodings/__init__.pyc 0 undefined

      at Object.openSync (../wasi/src/fs.ts:156:13)

  console.log
    mapFlags openSync /usr/lib/python3.11/encodings 0 undefined

      at Object.openSync (../wasi/src/fs.ts:156:13)

  console.log
    mapFlags openSync /usr/lib/python3.11/encodings/aliases.pyc 0 undefined

      at Object.openSync (../wasi/src/fs.ts:156:13)

  console.log
    mapFlags openSync /usr/lib/python3.11/encodings/utf_8.pyc 0 undefined

      at Object.openSync (../wasi/src/fs.ts:156:13)

  console.log
    mapFlags openSync /usr/lib/python3.11/lib-dynload 0 undefined

      at Object.openSync (../wasi/src/fs.ts:156:13)

  console.log

Maybe we can make a python-init.zip that is TINY and includes only those files. The main python.zip is only extracted and mounted slightly later after python has started...

williamstein commented 2 years ago

I implemented this already.