Why Hermes bytecode defeats binary diffing — and how we got a one-line OTA hotfix down to 3.4 KB
Disclosure: I maintain react-native-update , the open-source SDK behind Cresc, an OTA update service for React Native. The benchmark code and data are public, and the technique applies to anyone shipping Hermes bundles. If you ship React Native over-the-air updates, you've probably assumed binary diffing solves the bandwidth problem: compute a bsdiff between the old and new bundle, send the…
Hermes bytecode makes binary diffing ineffective for OTA updates in React Native apps. When shipping updates, it's assumed binary diffing will suffice, but this doesn't hold true for Hermes bytecode. The problem lies in how Hermes handles string tables, offset tables, and debug information. Every time the bytecode is compiled, the string table is re-sorted, which causes string IDs to change and affects numerous instructions referencing those IDs.
This results in large diffs for even small source changes. Hermes provides a "delta mode" that pins string IDs in place by compiling against the root bytecode of its version chain, reducing patch sizes significantly. Additionally, moving debug info out of the bytecode further shrinks the size before diffing. Another issue is the amplification of insertion edits due to Hermes bytecode's numerous tables storing absolute offsets.
Applying a reversible transform to delta-encode these offset fields reduces the impact of such edits, cutting patch sizes by an additional 9-36%. All these optimizations stack, making them especially beneficial for small changes, which is the ideal use case for OTA updates. The solution is safe, as bit-exact round trips and instruction-level equivalence checks ensure the patch is applied correctly.
The diffing technique is integrated into react-native-update and the hosted service Cresc, with a free tier available. The benchmark harness and raw data are publicly available for others to test and compare results.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.