[go: up one dir, main page]

Skip to content
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

Saving to IndexedDB instead of memfs #283

Open
andersson09 opened this issue Oct 31, 2021 · 4 comments
Open

Saving to IndexedDB instead of memfs #283

andersson09 opened this issue Oct 31, 2021 · 4 comments

Comments

@andersson09
Copy link

Hello

Is it possible to have a configuration that allows the executing WASI/WASM packages to store to a persistent storage provider such as IndexedDB rather than memfs?

Also my other question is slightly unrelated but can wasm-terminal also run WASM or only WASI packages?

Thanks!

@corwin-of-amber
Copy link
Contributor

Hi! I have recently implemented some logic in my own code (not part of wasmer) that synchronizes a memdb with an IndexedDB.
https://github.com/corwin-of-amber/Web.Author/blob/master/src/net/local.ts

It takes advantage of fs.watch. Unfortunately, memfs does not implement recursive watch... so I needed to wrap the memfs Volume with my own SubdirectoryVolume:
https://github.com/corwin-of-amber/Web.Author/blob/master/src/infra/volume.ts#L59

Feel free to copy my source 😄

I am afraid the (brilliant) TypeScript implementation of the wasmer runtime has been abandoned for now, so I do not much expect it to progress. But if you happen to add some functionality I am sure they will appreciate PRs.

@andersson09
Copy link
Author

Thanks will take a look. When writing to memfs does it individually store each file to the db and remove the file from memfs to clear space or does it just place whatever is inside memfs to indexeddb similarly to emscripten idbfs? My only concern would be how this deals with reading large file streams from db without loading anything to memory.

@corwin-of-amber
Copy link
Contributor

Ah, it's not very smart tbh. It makes a clone of whatever is in the memfs, which it stores in the IndexedDB. Then when you reload the page it reads the entire DB back to memory. Indeed for large files this would be infeasible.

@andersson09
Copy link
Author

Ah, it's not very smart tbh. It makes a clone of whatever is in the memfs, which it stores in the IndexedDB. Then when you reload the page it reads the entire DB back to memory. Indeed for large files this would be infeasible.

Thanks for the quick reply. That's useful to know.

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

No branches or pull requests

2 participants