Skip to content

SINGLE_FILE could use hex instead of base64 #7213

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
jedisct1 opened this issue Oct 2, 2018 · 3 comments
Closed

SINGLE_FILE could use hex instead of base64 #7213

jedisct1 opened this issue Oct 2, 2018 · 3 comments
Labels

Comments

@jedisct1
Copy link

jedisct1 commented Oct 2, 2018

The SINGLE_FILE flag causes the generated wasm code to be embedded within the JS code as a base64 string so it doesn't have to be loaded as an external dependency.

And this is awesome.

However, encoding wasm code as a hexadecimal string consistently provides smaller file sizes, after gzip compression, than base64. Between 5% and 8% smaller in the experiments I ran (libsodium, libhydrogen, and implementations of individual primitives).

Which kinda makes sense. Wasm opcodes repeat, and we can make better use of the dictionary if the same sequence of bytes always gets encoded the same way, unlike what base64 does.

In that context, would it make sense to encode wasm code as hex instead of base64 when SINGLE_FILE is used?

/cc @buu700

@buu700
Copy link
Contributor

buu700 commented Oct 2, 2018

lol, did you mean to submit the exact same issue immediately after me? (See #7211.)

Anyway, I'm totally onboard with this idea.

@jedisct1
Copy link
Author

jedisct1 commented Oct 2, 2018

Hahah, no, hadn't seen this. I was experimenting with libhydrogen and wasm yesterday and came to the same conclusion while trying to make it as small as possible.

Great, then :)

@stale
Copy link

stale bot commented Oct 2, 2019

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Oct 2, 2019
@stale stale bot closed this as completed Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants