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

Feature: (Ab)Use WASM for more efficient binary storage. #19

Open
NfNitLoop opened this issue Dec 4, 2024 · 1 comment
Open

Feature: (Ab)Use WASM for more efficient binary storage. #19

NfNitLoop opened this issue Dec 4, 2024 · 1 comment

Comments

@NfNitLoop
Copy link
Owner

Deno 2.1 adds even better support for loading WASM modules.

I bet storing binary data inside of a WASM file might be more space-efficient than storing it as base64 data inside of a .ts file.

Would be fun to implement a WASM option to compare the two.

@NfNitLoop
Copy link
Owner Author

NfNitLoop commented Dec 30, 2024

Question:

The current typescript-based implementation assumes that when passing a literal to a constructor like this:

new Foo(`some string literal`)

the string literal can be garbage-collected since it's never used again in code. This means that we can convert the base64-encoded version to a smaller Uint8Array representation. We may additionally choose to keep that representation compressed, or decompress it. But because the original literal is GC'd, we don't have to care about doubling memory usage.

But, does the WASM runtime allow for that? If a literal is encoded in the WASM file, and the WASM file is loaded into a state machine, it's just going to stay in memory for the entire lifetime of the WASM module, right?

That may still be fine if we load & keep compressed bytes directly from the module. But we'd also want to check on any inefficiencies that passing those bytes into JS might introduce.

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

1 participant