Skip to content

SINGLE_FILE could use hex instead of base64 #7213

Closed

Description

@jedisct1

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

Activity

  1. buu700 commented on Oct 2, 2018

    @buu700
    Contributor

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

    Anyway, I'm totally onboard with this idea.

  2. jedisct1 commented on Oct 2, 2018

    @jedisct1
    Author

    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 :)

  3. stale commented on Oct 2, 2019

    @stale

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions