React Native Blog Oct 26, 2021

Making Hermes the Default JavaScript Engine

Article Summary

Meta's Hermes team cut app startup time in half and reduced GC pauses by 34x. Here's how they're making it the default engine for React Native.

Meta's React Native team details the two-year journey to make Hermes the default JavaScript engine across all React Native platforms. The article covers major technical improvements including a new garbage collector, memory optimizations, and community-driven feature additions.

Key Takeaways

Critical Insight

Hermes delivers dramatic performance wins through ahead-of-time compilation, concurrent garbage collection, and aggressive memory optimization while expanding from Android-only to iOS, Windows, macOS, and VR platforms.

The article reveals how Meta's monorepo strategy enabled unique vertical integrations between Hermes and React Native that other engines can't match.

About This Article

Problem

React Native apps on Android had a serious problem with UI thread blocking. Hermes's garbage collector ran on a single thread and would pause everything to clean up memory. These pauses averaged 200ms, and in the worst cases on Facebook's app, they hit 7 seconds.

Solution

Meta's Hermes team built Hades, a new garbage collector that runs most of its work in the background. It uses a snapshot-at-the-beginning mark-sweep strategy for older memory sections, so JavaScript execution doesn't get blocked while collection happens.

Impact

Hades brought GC pause times down to 48ms at p99.9 on 64-bit devices and 88ms on 32-bit devices. The team also optimized memory usage through aggressive header layout compression, which cut memory by another 15% on top of the 30% savings they already got from 32-bit encoding.