Conversation
executeMount called SetIntArrayRegion for every writeInt/writeIntArray, ~4.5k JNI calls for a commit mounting 1500 views. The exact size is already known from computeBufferSizes, so fill a std::vector<jint> and copy it once before createIntBufferBatchMountItem. The int[] Java receives is unchanged. Changelog: [ANDROID] [CHANGED] - Write Fabric mount instruction ints to Java in a single JNI call Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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:
FabricMountingManager::executeMountwrote the int buffer to Java with oneSetIntArrayRegionperwriteInt/writeIntArray, which is ~4.5k JNI calls for a commit that mounts 1500 views. The exact size is already known fromcomputeBufferSizes, so this fills astd::vector<jint>instead and copies it once beforecreateIntBufferBatchMountItem. Theint[]Java receives is identical.GetPrimitiveArrayCriticalisn't an option here since the object writes call into Java between int writes, and on ARTGetIntArrayElementscopies movable arrays anyway.Time spent in
executeMountfor one commit on an OPPO CPH2667 (Dimensity 6300, Android 16), release build. Each cell is the median over 114 commits from 6 interleaved runs:The slowest commits improve more (e.g. 19.6 → 6.4 ms when restyling). The int transfer on its own goes from 174 → 87 µs per 1500-view commit. On an Apple silicon emulator JNI calls are ~5x cheaper and the difference is within noise.
Changelog:
[ANDROID] [CHANGED] - Write Fabric mount instruction ints to Java in a single JNI call
Test Plan:
int[]the old way and compares it with the array sent to Java on every commit: 1390 commits on device and 782 on emulator across Playground (1500 views), FlatList, Text and Image, 0 mismatches.yarn androidand release) on device and emulator: Playground, FlatList, Text and Image render as before.yarn lint,yarn flow-check,yarn format-check-cpppass.FabricMountingManagerTest/FabricMountingManagerInstrumentationTest, they're Buck-only.🤖 Generated with Claude Code