Repository navigation
[Android] Report JS thread work to Android performance hints - #60525
Open
hryhoriiK97 wants to merge 1 commit into
Open
hryhoriiK97 wants to merge 1 commit into
hryhoriiK97 wants to merge 1 commit into
Conversation
The JS thread works in short bursts separated by idle time, so the Android scheduler keeps it on slow cores at low frequency. Behind the new enableJSThreadPerformanceHintAndroid flag, the bridgeless JS thread now gets an ADPF hint session (Android 12+). Each burst of messages is reported when the next burst starts, because the session's boost expires during the idle time before then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Gregory Moskaliuk <gregory.moskaliuk@swmansion.com>
hryhoriiK97
marked this pull request as draft
December 4, 2026 07:41
hryhoriiK97
marked this pull request as ready for review
December 4, 2026 09:43
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
The JS thread works in short bursts, such as one React update, with idle time in between. The Android scheduler sees a mostly idle thread and keeps it on the slow cores, at low frequency. On a Pixel 9a, the same 341-view update takes 22 ms of JS this way and 7 ms when the thread is boosted. Android already gives the UI thread and RenderThread a performance hint session (ADPF) through HWUI; the JS thread has none.
Behind a new flag,
enableJSThreadPerformanceHintAndroid(off by default), the bridgeless JS thread gets its own hint session on Android 12+:MessageQueueThreadHandlertells a listener when each message starts and ends.MessageQueueThreadBurstTrackergroups the messages handled back to back, until the queue has nothing due, into a burst.MessageQueueThreadPerformanceHintreports bursts to a session with an 8 ms target (half a 60 Hz frame).A burst is reported when the next one starts, not when it ends. The system drops a session's boost when no reports arrive for a while. Reported at its end, a burst gave no speedup at all: the boost had expired by the time the next update started. Reported when work resumes, it applies to the work that is starting. Java has no public way to say "work is starting":
Session.sendHintis hidden, andAPerformanceHint_notifyWorkloadIncreaseis NDK-only on Android 16+.Some details:
Cost: a faster core uses more energy. On the Pixel 9a, during the busy test below (an update every 200 ms), batterystats estimates the app's CPU power at +40% (0.177 → 0.249 mAh per minute). When the JS thread is idle, nothing changes. That trade-off is why the flag is off by default.
Changelog:
[ANDROID] [ADDED] - Add the
enableJSThreadPerformanceHintAndroidfeature flag, which reports JS thread work to Android performance hints so that long JS work runs on faster coresTest Plan:
Unit tests:
MessageQueueThreadBurstTrackerTest(6 tests) covers:1,125 tests in 146 suites pass.
yarn android-api-buildleavesReactAndroid.apiunchanged,node packages/react-native/scripts/featureflags/index.js --verify-unchangedpasses, andyarn format-check-kotlinpasses for the changed files.Devices: RNTester release builds of this branch, with the flag off and on, three interleaved launches each.
Views (not memoized) where one leaf changes size;setStateto the layout effect. "Mounted" is the time untilUIManagerListener.didMountItems. Both are medians.🤖 Generated with Claude Code