Skip to content

Fix per-node memory regression caused by Grid styles - #58311

Open
javache wants to merge 1 commit into
react:mainfrom
javache:export-D118628661
Open

Fix per-node memory regression caused by Grid styles#58311
javache wants to merge 1 commit into
react:mainfrom
javache:export-D118628661

Conversation

@javache

@javache javache commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary:

Why

Currently, grid style properties are stored in yoga style (gridTemplateRows_, gridAutoColumns_ etc). These properties increase the size of style object from 152 bytes to 280 bytes (84% increase). The cost is added even when a node is not a grid container or a grid item.

How

Move grid style properties behind a pointer that is lazily allocated, on the first grid property set. A node that doesn't use grid only adds the cost of this pointer (8 bytes). So style now costs 160 bytes (5% increase). The public API remains unchanged.

Tests

A test is added to catch the style size regression and tests/GridStyleTest.cpp includes additional cases to assert unset style, copy and move behaviour.

X-link: react/yoga#2018

Differential Revision: D118628661

Pulled By: javache

Summary:
# Why

Currently, grid style properties are stored in yoga style (`gridTemplateRows_`, `gridAutoColumns_` etc). These properties increase the size of style object from `152` bytes to `280` bytes (84% increase). The cost is added even when a node is not a grid container or a grid item.

# How

Move grid style properties behind a pointer that is lazily allocated, on the first grid property set. A node that doesn't use grid only adds the cost of this pointer (8 bytes). So style now costs 160 bytes (5% increase). The public API remains unchanged.

# Tests

A test is added to catch the style size regression and `tests/GridStyleTest.cpp` includes additional cases to assert unset style, copy and move behaviour.

X-link: react/yoga#2018

Differential Revision: D118628661

Pulled By: javache
@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 3, 2026
@meta-codesync

meta-codesync Bot commented Sep 3, 2026

Copy link
Copy Markdown

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

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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants