diff --git a/patches/react-native/details.md b/patches/react-native/details.md index 728052b2c2696..be59cade91d99 100644 --- a/patches/react-native/details.md +++ b/patches/react-native/details.md @@ -196,3 +196,17 @@ - Upstream PR/issue: There won't be any upstream changes. We need to get rid of InteractionManager - E/App issue: https://github.com/Expensify/App/issues/71913 - PR introducing patch: https://github.com/Expensify/App/pull/69535 + +### [react-native+0.81.4+026+perf-increase-initial-heap-size.patch](react-native+0.81.4+026+perf-increase-initial-heap-size.patch) + +- Reason: This patch increases the initial heap size of the Hermes runtime. This allows us to disable Hermes Young-Gen Garbage Collection (GC) in a separate patch, which improves initial TTI and app startup time. +- Upstream PR/issue: This is not intended to be upstreamed, since this is a low-level fix very specific to the Expensify app's requirements. +- E/App issue: [#76859](https://github.com/Expensify/App/issues/76859) +- PR introducing patch: [#76154](https://github.com/Expensify/App/pull/76154) + +### [react-native+0.81.4+027+perf-disable-hermes-young-gc-before-tti-reached.patch](react-native+0.81.4+027+perf-disable-hermes-young-gc-before-tti-reached.patch) + +- Reason: This patch disables Hermes Young-Gen Garbage Collection (GC), which improves initial TTI and app startup time, by delaying GC for early allocated memory to the first Old-Gen GC run. +- Upstream PR/issue: This is not intended to be upstreamed, since this is a low-level fix very specific to the Expensify app's requirements. +- E/App issue: [#76859](https://github.com/Expensify/App/issues/76859) +- PR introducing patch: [#76154](https://github.com/Expensify/App/pull/76154) diff --git a/patches/react-native/react-native+0.81.4+026+perf-increase-initial-heap-size.patch b/patches/react-native/react-native+0.81.4+026+perf-increase-initial-heap-size.patch new file mode 100644 index 0000000000000..f2740e91d968a --- /dev/null +++ b/patches/react-native/react-native+0.81.4+026+perf-increase-initial-heap-size.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp b/node_modules/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp +index d09f3a7..9018067 100644 +--- a/node_modules/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp ++++ b/node_modules/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp +@@ -126,6 +126,8 @@ std::unique_ptr HermesInstance::createJSRuntime( + assert(msgQueueThread != nullptr); + + auto gcConfig = ::hermes::vm::GCConfig::Builder() ++ .withInitHeapSize(150ll * 1024 * 1024) ++ .withShouldReleaseUnused(::hermes::vm::kReleaseUnusedNone) + // Default to 3GB + .withMaxHeapSize(3072 << 20) + .withName("RNBridgeless"); diff --git a/patches/react-native/react-native+0.81.4+027+perf-disable-hermes-young-gc-before-tti-reached.patch b/patches/react-native/react-native+0.81.4+027+perf-disable-hermes-young-gc-before-tti-reached.patch new file mode 100644 index 0000000000000..02cdb490a967f --- /dev/null +++ b/patches/react-native/react-native+0.81.4+027+perf-disable-hermes-young-gc-before-tti-reached.patch @@ -0,0 +1,17 @@ +diff --git a/node_modules/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp b/node_modules/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp +index 9018067..405a36f 100644 +--- a/node_modules/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp ++++ b/node_modules/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp +@@ -132,7 +132,11 @@ std::unique_ptr HermesInstance::createJSRuntime( + .withMaxHeapSize(3072 << 20) + .withName("RNBridgeless"); + +- if (allocInOldGenBeforeTTI) { ++ // By enabling the `allocInOldGenBeforeTTI` flag, we prevent ++ // Hermes from running Young-Gen GC before TTI, ++ // which saves around 150-200ms on initial load. ++ // Once Old-Gen GC is triggered, it will enable Young-Gen GC again. ++ if (/*allocInOldGenBeforeTTI*/ true) { + // For the next two arguments: avoid GC before TTI + // by initializing the runtime to allocate directly + // in the old generation, but revert to normal