Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions patches/react-native/details.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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<JSRuntime> 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");
Original file line number Diff line number Diff line change
@@ -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<JSRuntime> 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
Loading