bytecodealliance / bytecodealliance/wasmtime-py
When used with ComponentizeJS output, `wasmtime.Module.from_file` is extremely slow and not configurable
- Dominant language
- Python
- Stars
- 539
- Forks
- 69
- Avg merge
- 13m
- Merged PRs (30d)
- 1
Description
I have a really simple component with this WIT world:
```wit
package local:wavedrom;
world wavedrom {
export render-json: func(json: string) -> string;
}
```
After running through ComponentizeJS, it results in a 14 MB `.component.wasm` file. This is essentially reasonable, I've used much bigger ones.
However, when I try using it with this equally simple wrapper:
```py
import json
import wasmtime
from . import _bindings
def render(source):
store = wasmtime.Store()
return _bindings.Root(store).render_json(store, json.dumps(source))
```
I discover that the `wasmtime.Module.from_file` call takes almost 4 seconds to execute on my machine (!). This is actually slow enough that I will not be able to use the component in the intended application, and will have to embed a JS engine in some other way.
In YoWASP/runtime-py I have [a bunch of code](https://github.com/YoWASP/runtime-py/blob/71f06fe6db805460a8c728cfd3a54449016edc07/yowasp_runtime/__init__.py#L86-L105) that caches the compiled executable code, and it works extremely well for other YoWASP tools. However, the generated bindings offer me no way to inject this code.
What do I do?
Contributor guide
Assessment
This issue has not been assessed yet.