Skip to content

perf: Faster WritableNativeMap.putString value conversion - #58644

Open
riteshshukla04 wants to merge 1 commit into
react:mainfrom
riteshshukla04:perf/writable-native-map-putstring
Open

riteshshukla04 wants to merge 1 commit into
react:mainfrom
riteshshukla04:perf/writable-native-map-putstring

Conversation

@riteshshukla04

@riteshshukla04 riteshshukla04 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary:

I found (while working on #58611) that WritableNativeMap::putString converted its value with fbjni toString(), which calls Java Object.toString() through JNI before running toStdString(). Since the value is already a jstring, I call toStdString() directly, which produces identical bytes with one fewer JNI call and local reference.

Value Before After Delta
11 ASCII 0.205 0.191 -6.8%
100 ASCII 0.265 0.231 -12.8%
300 ASCII 0.451 0.418 -7.3%
1000 ASCII 0.984 0.966 -1.8%
100 CJK 0.325 0.298 -8.3%

Changelog:

[ANDROID] [CHANGED] - Skip a redundant JNI Object.toString() call in WritableNativeMap.putString.

Test Plan:

I measured putString at 0.614 → 0.474 µs per call for short strings (-23%) on a Galaxy M14, identical output on 21 edge-case strings.

@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 23, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 23, 2026

This branch has not been deployed

No deployments
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant