Hermes: Hermes takes 140MB in node_modules

Created on 6 Mar 2020  路  6Comments  路  Source: facebook/hermes

Hermes publishes a variety of builds for every major OS out there to npm:

4.0M    ./osx-bin
 91M    ./linux64-bin
 35M    ./win64-bin

While the binary size for OSX seems reasonable, I wonder if we could get lower with Windows and Linux?

Unfortunately I have no experience with native build tooling, so I'm afraid I won't be able to help too much. But I wanted to spark discussion around the topic, to keep it in mind. Or close, if it turns out that there's no unnecessary code bundled within Linux/Win binaries.

enhancement

Most helpful comment

I think we could (should?) just ship the compiler and only a single Wasm version at that. That should bring our size down dramatically.

All 6 comments

This is primarily due to the bundled Unicode ICU libraries. macOS is small because they ship with the OS. Linux is especially large because the binaries are statically linked, which means ICU and other libs are included twice.

There's been no work invested into trying to reduce the size of the host binaries, so there's definitely low hanging fruit. For example, I just landed cf1eca8a85c85b0c20af2a7dce7582e23781366b which reduces it by 30MB just by stripping the Linux binaries.

The second lowest hanging fruit is probably to link Linux binaries dynamically (with -Wl,-rpath=$ORIGIN), and bundling them with shared versions of the libraries like on Windows, which would save another ~30MB.

Thank you, that's awesome!

I think we could (should?) just ship the compiler and only a single Wasm version at that. That should bring our size down dramatically.

With 284ae5e70d6bb2c7d98e859e74907c68ae6abae0 we'll be removing the host runtime and repl from the hermes-engine NPM, including the ICU they depend on, and instead just include the bytecode compiler.

When released, v0.5.0 will take less than 20MB of space!

Anyone depending on these tools can still easily get them (plus a few more) in a separate NPM that's not yet published.

Amazing, thank you so much. I believe we can close this issue now. @tmikov could you create a new issue for Wasm version so it's harder to forget? It's an interesting idea :)

@thymikee for now we are not planning to ship a Wasm build of hermesc in the npm because the additional savings from that are relatively small - only about 3 additional MB out of 20. It already is possible to build it, if someone needs it, we are just not shipping it by default.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gaodeng picture gaodeng  路  4Comments

mathiasbynens picture mathiasbynens  路  6Comments

benkane picture benkane  路  5Comments

haozhun picture haozhun  路  6Comments

jacque006 picture jacque006  路  4Comments