Live data from Hacker News

Hermes – A small JavaScript engine optimized for running React Native on Android

github.com

41–50 of 57 posts

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#42
post #22
post #5

Earlier quoted context omitted.

We have done some internal tests of Hermes on a RN experience within Microsoft Office on Android. Currently we use V8 with bytecode caching on Android, since it provided better startup performance than the JSC engine that normally ships within RN. So the baseline is likely already faster than stock RN. V8 runtime Memory Impact: 30MB Hermes runtime memory impact: 21.5MB V8 time to interaction: 1.4s Hermes time to inte…

Very nice numbers, although worth mentioning hermes only appears to support es5, so there's way less stuff to load.

Hermes compiles JS ahead of time to bytecode. The VM takes bytecode in as input, not source code. The ES5 vs. ES6 distinction doesn't matter as much as in other engines where the runtime takes source code as input, and as a result has to pay the more expensive ES6 parsing cost at runtime.

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#43
post #29

There's a gazillion engineering hours between JavaScriptCore and V8. It seems crazy to write a JS engine from scratch as opposed to forking JSC or V8. (For the unawares, RN necessarily uses the system JSC on iOS per Apple requirements, but for Android RN bundles JSC into the APK.) I don't understand how Hermes will differ from JSC/V8 in terms of functionality and performance. What functionality can be left out of Her…

It's not an unreasonable task for a small team of skilled engineers who know V8 in depth, the kind that FB can and probably has recruited. If they're taking most of what V8 learned over the years into account, they'll know what to prioritize and what to not to.

They also probably know about the tradeoffs. V8 has to choose when interpret and when to compile, when to load things into memory, when to garbage-collect, etc. and they do so keeping in mind it is running javascript from the internet, for any kind of application, on any kind of device.

Hermes can make many more assumptions and so the engineers, even if they built something very similar to V8, can probably dial the knobs much more differently to optimize for what Hermes cares about.

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#44

Earlier quoted context omitted.

V8 and JSC are absolutely amazing pieces of technology. They'll run 60fps WebGL games or console emulators at incredible speeds. Huge props to the engineers that made that happen! RN apps are rarely CPU bound though, so they don't necessarily benefit as much from those same optimizations.

All those laggy react apps aren't CPU bound? What else is making them laggy?

Poor coding practices, bad state management, and lack of encapsulation between UI components and business logic / data retrieval.

It's really easy to build a React Native app, but not easy to build a really good one.

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#45
post #39
post #29

There's a gazillion engineering hours between JavaScriptCore and V8. It seems crazy to write a JS engine from scratch as opposed to forking JSC or V8. (For the unawares, RN necessarily uses the system JSC on iOS per Apple requirements, but for Android RN bundles JSC into the APK.) I don't understand how Hermes will differ from JSC/V8 in terms of functionality and performance. What functionality can be left out of Her…

The same real world react app went from 40MB to 20MB. They don't ship minified javascript to final app, but bytecode, which they say is 1/3 smaller (both minified). They have moved the parse and compile stages to ahead of time, making the VM smaller, and giving the bytecode benefit. The bytecode benefit also means a quicker time to live/first reponse from 4s to 2s in their example. Link to the talk, from FB employee…

This is actually huge and will probably only get better, especially considering now they own their whole JS stack: the framework (React/RN), the language (Flow [1]) and now the VM.

It sounds like Hermes is exclusively for running React Native on mobile. They could start building React directly into Hermes— the reconciling algorithm for example, or maybe even some real parallelism.

Very curious to see how all this keeps evolving.

[1]: https://github.com/facebook/flow

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#46
post #39
post #29

There's a gazillion engineering hours between JavaScriptCore and V8. It seems crazy to write a JS engine from scratch as opposed to forking JSC or V8. (For the unawares, RN necessarily uses the system JSC on iOS per Apple requirements, but for Android RN bundles JSC into the APK.) I don't understand how Hermes will differ from JSC/V8 in terms of functionality and performance. What functionality can be left out of Her…

The same real world react app went from 40MB to 20MB. They don't ship minified javascript to final app, but bytecode, which they say is 1/3 smaller (both minified). They have moved the parse and compile stages to ahead of time, making the VM smaller, and giving the bytecode benefit. The bytecode benefit also means a quicker time to live/first reponse from 4s to 2s in their example. Link to the talk, from FB employee…

Ah, gotcha. It's moving the parse/compile AOT that I missed. Naively, I'm still surprised they didn't start with JSC/V8 but maybe those engines carry a lot more in them than is needed. Thank you for the link.

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#47
post #29

There's a gazillion engineering hours between JavaScriptCore and V8. It seems crazy to write a JS engine from scratch as opposed to forking JSC or V8. (For the unawares, RN necessarily uses the system JSC on iOS per Apple requirements, but for Android RN bundles JSC into the APK.) I don't understand how Hermes will differ from JSC/V8 in terms of functionality and performance. What functionality can be left out of Her…

Proof is in the pudding: 28% startup speed improvement in MS Office for Android vs V8 with bytecode caching (so AOT compiling the bytecode isn’t a big advantage specific to Hermes):

https://news.ycombinator.com/item?id=20413046

The key is that Hermes is optimized for a totally different environment and workload - RN apps from disk on slow Android devices vs. websites downloaded on desktop computers.

The fact that Hermes is architected for RN from the beginning is key. Bytecode is as compact as possible, and is mmap’d. mmap’d bytecode is a very deep change with huge benefits, but also limits some optimizations other engines rely on, such as inline caching.

Also note Hermes does not have a JIT to save memory and APK size. A lot of the heroic perf work in V8/JSC is in the JIT which is not useful in most RN scenarios/environments.

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#48
post #27
post #19

Not clear what version of JS spec it supports. And what are these "optimizations for running React Native on Android". Just reducing startup/boot time or what?

The VM doesn't run JS directly, just bytecode so the version of the spec supported doesn't matter much. JS can be run through babel before going through the Hermes compiler.

wonderful

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#49
post #34

Worth noting that JSC on iOS for use in app-backend/business-logic code runs in interpreted mode [1]. Are Android versions of RN apps faster because Android's native V8 allows JIT, and Hermes also employs JIT? [1]: https://stackoverflow.com/questions/45422462/what-does-jit-i...

RN on Android also uses JSC, so no JIT. And, and per the video (https://www.youtube.com/watch?v=zEjqDWqeDdg&feature=youtu.be...) there is no JIT on Hermes either.

Re: Hermes – A small JavaScript engine optimized for running React Native on Android

#50
post #5
post #2

They harp a lot on how fast it starts up - which sounds great - but I would like to have some solid numbers on what that startup time actually is on actual devices! I can't seem to find anything perusing around the GH page or the site

We have done some internal tests of Hermes on a RN experience within Microsoft Office on Android. Currently we use V8 with bytecode caching on Android, since it provided better startup performance than the JSC engine that normally ships within RN. So the baseline is likely already faster than stock RN. V8 runtime Memory Impact: 30MB Hermes runtime memory impact: 21.5MB V8 time to interaction: 1.4s Hermes time to inte…

It's a pity the Proxy is not supported mobx is really much nicer approach to state management and usually, apps using mobx are much faster - simply because implementing shouldComponentUpdate properly is hard
Post reply on HN