Skip to content

Reduce JNI allocations when importing native maps (#58274) - #58274

Closed
javache wants to merge 1 commit into
react:mainfrom
javache:export-D118277119
Closed

Reduce JNI allocations when importing native maps (#58274)#58274
javache wants to merge 1 commit into
react:mainfrom
javache:export-D118277119

Conversation

@javache

@javache javache commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary:

ReadableNativeMap materialization copied keys and created temporary JNI references for every imported type. Cache pointers to the stable native values and reuse global ReadableType references so importing maps and arrays does less allocation and lookup work.

Writable maps can continue mutating after materialization because folly::dynamic stores object entries in reference-stable F14NodeMap nodes.

Changelog: [Internal]

Reviewed By: christophpurrer, rubennorte

Differential Revision: D118277119

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 1, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Sep 1, 2026
@meta-codesync

meta-codesync Bot commented Sep 1, 2026

Copy link
Copy Markdown

@javache has exported this pull request. If you are a Meta employee, you can view the originating Diff in D118277119.

@meta-codesync meta-codesync Bot changed the title Reduce JNI allocations when importing native maps Reduce JNI allocations when importing native maps (#58274) Sep 2, 2026
javache added a commit to javache/react-native that referenced this pull request Sep 2, 2026
Summary:

`ReadableNativeMap` materialization copied keys and created temporary JNI references for every imported type. Cache pointers to the stable native values and reuse global `ReadableType` references so importing maps and arrays does less allocation and lookup work.

Changelog: [Internal]

Differential Revision: D118277119
javache added a commit to javache/react-native that referenced this pull request Sep 2, 2026
Summary:

`ReadableNativeMap` materialization copied keys and created temporary JNI references for every imported type. Cache pointers to the stable native values and reuse global `ReadableType` references so importing maps and arrays does less allocation and lookup work.

Changelog: [Internal]

Differential Revision: D118277119
@meta-codesync meta-codesync Bot changed the title Reduce JNI allocations when importing native maps (#58274) Reduce JNI allocations when importing native maps Sep 2, 2026
Summary:

`ReadableNativeMap` materialization copied keys and created temporary JNI references for every imported type. Cache pointers to the stable native values and reuse global `ReadableType` references so importing maps and arrays does less allocation and lookup work.

Writable maps can continue mutating after materialization because `folly::dynamic` stores object entries in reference-stable `F14NodeMap` nodes.

Changelog: [Internal]

Reviewed By: christophpurrer, rubennorte

Differential Revision: D118277119
@meta-codesync meta-codesync Bot changed the title Reduce JNI allocations when importing native maps Reduce JNI allocations when importing native maps (#58274) Sep 4, 2026
@meta-codesync meta-codesync Bot closed this in bf0e377 Sep 4, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Sep 4, 2026
@meta-codesync

meta-codesync Bot commented Sep 4, 2026

Copy link
Copy Markdown

This pull request has been merged in bf0e377.

@javache
javache deleted the export-D118277119 branch September 4, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant