Mikov contrasts web engines, which parse, compile, and optimize at runtime, with Hermes, which compiles ahead of time to bytecode. Hermes loads that bytecode lazily, keeping startup work and memory use low. Its startup time does not depend on the size of the input bundle.
Hermes: better performance with runtime bytecode translation
Speaker
Tzvetan Mikov, a member of Meta’s Hermes team, presents new work on Hermes performance at RUC 2024, hosted by Callstack.
Static Hermes uses type annotations to compile typed bytecode or native machine code. Mikov says it can approach C++ performance without relying on repeated runtime guesses about types. Adoption is complicated because build pipelines often erase annotations, native compilation makes over-the-air updates harder, and untyped JavaScript still needs to run well.
Hermes translates bytecode instructions into machine instructions on the device, reducing the interpreter’s instruction decoding and dispatch work. Apps can still ship bytecode and use over-the-air updates. Mikov calls the approach bytecode translation; technically it is a JIT, but it avoids speculative optimization by building on Hermes’s ahead-of-time compiler.
On several Octane benchmarks, untyped code runs about 50% faster with translation. In typed benchmarks, the Ray Tracer runs nine times faster with typed bytecode and translation than with original Hermes, while native code is faster still by a smaller margin. Mikov also shows an untyped Mandelbrot renderer that ran faster than he expected.
Mikov explains that replacing bytecode instructions with function calls gave almost no improvement. Performance improved when common cases, such as numeric multiplication, got a fast path and unusual cases branched to slower handling. He expects bytecode translation to arrive before default support for static types, which depends on preserving annotations through build pipelines.
Takeaways
- Moving parsing and compilation off the device can reduce startup work and memory use.
- A lightweight bytecode translator can improve untyped performance while preserving bytecode delivery and over-the-air updates.
- Type information can unlock larger gains, but only if build pipelines preserve annotations.
- For runtime optimization, fast paths for common operations can matter more than routing every instruction through a function call.
- Plan performance improvements for untyped code too, since typed code may cover only part of an application.
Mentioned in this talk
Search inside this talk
What was claimed 12
- role atTzvetan Mikov is Hermes team member at
Meta
“I'm on the Hermes team at Meta.”
YouTube Verified3 sources· Talk
- feature
Hermes Agent: Designed and optimized for mobile usage and very fast startup
“it was designed and optimized for mobile usage”
YouTube Unverified1 source· Talk
- feature
Hermes Agent: Default JavaScript engine for React Native
“Hermes is the default engine for React Native”
YouTube Unverified1 source· Talk
- feature
Hermes Agent: Ahead-of-time compilation to bytecode; bytecode is loaded lazily at runtime
“Everything is happening at build time: parsing, compilation, and optimization.”
YouTube Unverified1 source· Talk
- metric
Hermes Agent: Performance comparable to C++
“Static Hermes to achieve performance comparable to C++”
YouTube Unverified1 source· Talk
- feature
Hermes Agent: Understands type annotations and emits typed bytecode or native machine code
“Static Hermes can emit either typed bytecode or native machine code.”
YouTube Unverified1 source· Talk
- feature
Hermes Agent: Available on GitHub
“Static Hermes is available on GitHub”
YouTube Unverified1 source· Talk
- uses
“introduce our solution ... bytecode translation on device”
YouTube Unverified1 source· Talk
- featurebytecode translation: Retains bytecode shipping and over-the-air updates while improving performance
“continue to ship bytecode like you do today, enjoy the benefits of over-the-air updates”
YouTube Unverified1 source· Talk
- featurebytecode translation: Translates bytecode instructions to machine instructions at runtime
“very cheaply translating bytecode instructions to machine instructions at run time”
YouTube Unverified1 source· Talk
- metricbytecode translation: About 50% improvement across several Octane benchmarks
“they all improved by about 50%”
YouTube Unverified1 source· Talk
- metricbytecode translation: Ray Tracer was nine times faster with typed bytecode translation than original Hermes
“The Ray Tracer is nine times faster.”
YouTube Unverified1 source· Talk






