Skip to content

Persistent interpreter instances #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
guregu opened this issue Aug 7, 2022 · 2 comments · Fixed by #6
Closed

Persistent interpreter instances #4

guregu opened this issue Aug 7, 2022 · 2 comments · Fixed by #6

Comments

@guregu
Copy link
Collaborator

guregu commented Aug 7, 2022

Currently all queries go through a fresh interpreter. It would be nice to keep them alive so they can keep their knowledge base contents between requests.

I'm not sure how easy it will be because the stdin interfaces for Go WASM libraries don't look so great. Would be really nice to be able to pass an io.Reader to them.
Might be possible to work around by exporting Go/C functions and calling from Trealla FFI (need to add FFI to Trealla WASM first).

@guregu
Copy link
Collaborator Author

guregu commented Aug 8, 2022

This would be easy if this issue were fixed: wasmerio/wasmer-go#338
Seems like that issue is blocked by this... wasmerio/wasmer#2334 which could maybe be resolved by this wasmerio/wasmer#3032 (and of course needs to make its way to the Go lib).

Perhaps WasmEdge has better support? Not sure 🤔

One crazy trick I tried was using mkfifo and reading from inside WASM and it seems to work fine, so I'm thinking we can use FIFOs as a kind of temporary workaround. This won't work on Windows but neither does wasmer-go at the moment.

@guregu
Copy link
Collaborator Author

guregu commented Aug 10, 2022

Played around with named pipes. I think it could probably work but it adds a lot of complexity, including filesystem stuff that I would rather avoid. At that point it's probably better to just execute tpl in a subprocess.

I think exposing a host function is the best option, probably. Not sure how to actually do this yet.

@guregu guregu mentioned this issue Sep 25, 2022
@guregu guregu closed this as completed in #6 Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant