You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
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.
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
The text was updated successfully, but these errors were encountered: