Skip to content

Skip measuring prop names that RawPropsParser expects next - #60521

Draft
tomekzaw wants to merge 1 commit into
react:mainfrom
tomekzaw:@tomekzaw/rawprops-skip-strlen
Draft

tomekzaw wants to merge 1 commit into
react:mainfrom
tomekzaw:@tomekzaw/rawprops-skip-strlen

Conversation

@tomekzaw

@tomekzaw tomekzaw commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Props constructors read their props through RawProps::at(const char*), in the order the parser recorded during prepare, passing the same string literals every time. RawProps::at converted each name to a std::string_view before handing it to RawPropsParser::at. That conversion is a strlen of the prop name, for every prop of every node, including the many props a node does not set: BaseViewProps alone reads well over a hundred names.

In a simpleperf profile of a 40-row feed mount in RNTester (release, Galaxy A16), __strlen_aarch64 was 10.9% of UIManager::createNode samples, or 3.0% of all JS-thread samples during the mount.

RawPropsParser now has an at(const RawProps&, const char*) overload. If the pointer equals the stored std::string_view of the next expected key, and the name's terminator sits at that key's length, the cursor advances without measuring the name. The terminator check confirms the length in O(1). Any other name (out of order, repeated, or built at runtime) falls back to the existing std::string_view lookup, so behaviour does not change. The prefix/suffix overload of RawProps::at still builds a std::string and keeps using the std::string_view path.

This builds on #59657, which compares the pointers before the characters; that comparison only happens after the name has been measured.

Changelog:

[GENERAL] [CHANGED] - Skip measuring prop names that RawPropsParser reads in the expected order

Test Plan

  • New RawPropsTest.handleRawPropsNamesFromOtherStorage: names with the same characters at other addresses, in order and out of order, and a longer name that starts with a prepared one (intValueX), which must not match.

  • All ReactCommon C++ tests pass on macOS via the Fantom tester (./gradlew :private:react-native-fantom:testReactCommon): 1631 passed, including the new test.

  • node scripts/clang-format.js --check on the changed files.

  • RNTester release on real phones (Galaxy A16 and Pixel 9a), interleaved A/B of 5dc1d78 with and without this change, same toolchain: 12 blocks in random order × 20 rounds, each round mounting a 10-row and a 40-row feed of Views and Texts (n = 240 pairs per cell, every block at thermal status 0). JS-thread CPU from the start of the render until React's layout effect (render, createNode, commit and layout), median, ratio after/before with bootstrap 95% CI:

    Device Rows Before After Ratio [95% CI]
    Galaxy A16 10 46.8 ms 45.9 ms 0.981 [0.969, 0.992]
    Galaxy A16 40 149.2 ms 145.1 ms 0.973 [0.969, 0.976]
    Pixel 9a 10 22.6 ms 21.5 ms 0.990 [0.957, 1.009]
    Pixel 9a 40 77.9 ms 78.2 ms 1.001 [0.977, 1.014]

    On the A16 this matches the strlen share in the profile. On the Pixel 9a the difference is within noise. Time from the trigger to the frame that shows the content did not change on either device; the change only touches the JS thread.

🤖 Generated with Claude Code

Props constructors read their props in the order the parser recorded them,
passing the same string literals each time. `RawProps::at(const char*)`
turned each name into a `std::string_view`, which runs `strlen` before the
parser compares it with the expected key.

The parser now takes the `const char*` directly. When it is the pointer
stored for the next key and ends where that key ends, the cursor advances
without measuring the name; any other name falls back to the existing
`std::string_view` lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 3, 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

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant