Optimize style value resolution with handle-based approach#1922
Open
paradowstack wants to merge 1 commit intofacebook:mainfrom
Open
Optimize style value resolution with handle-based approach#1922paradowstack wants to merge 1 commit intofacebook:mainfrom
paradowstack wants to merge 1 commit intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
2 tasks
|
@NickGerleman has imported this pull request. If you are a Meta employee, you can view this in D99006553. |
NickGerleman
pushed a commit
to NickGerleman/react-native
that referenced
this pull request
Apr 1, 2026
Summary: This PR is an optimization attempt during work on the `calc()` feature: facebook/yoga#1874. It aims to reduce the regression effect on layout operations after extending the size of `StyleLength` and `StyleSizeLength` classes. ## Changelog: This PR introduces a private `resolve(StyleValueHandle handle, float referenceLength)` function to `Style.h` that resolves its property values directly from `StyleValueHandle` and skips creating intermediate objects. I am aware that this duplicates the resolving functionality that already exists in `StyleLength.h` and `StyleSizeLength.h`, and may not be the cleanest solution. Optimization could go even further and totally drop the `resolve()` function from `StyleLength.h` and `StyleSizeLength.h`, and replace all usages with the newly introduced functions. But I think the performance boost is not high enough to justify that. Also it won't be the best API for Yoga library consumers - that's why I decided to keep them. However, I am opening this PR to start a discussion and would really like to hear opinions about it. ## Benchmarks: Results were averaged over 20 runs. This does not bring much gain in terms of performance when compared to the main branch. <img width="1366" height="254" alt="image" src="https://github.com/user-attachments/assets/19ec2a31-db60-46bc-84e1-5ad8eb9ddfcd" /> However, it introduces a significant boost for the calc() and YGValueDynamic work. Results before these optimizations: <img width="1390" height="276" alt="image" src="https://github.com/user-attachments/assets/68c17e88-78e2-439b-bf09-acb869d5533d" /> And after: <img width="1363" height="252" alt="image" src="https://github.com/user-attachments/assets/212b9d11-5e02-4524-b9ba-90b43130d02c" /> cc NickGerleman X-link: facebook/yoga#1922 Reviewed By: zeyap Differential Revision: D99006553 Pulled By: NickGerleman
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:
This PR is an optimization attempt during work on the
calc()feature: #1874.It aims to reduce the regression effect on layout operations after extending the size of
StyleLengthandStyleSizeLengthclasses.Changelog:
This PR introduces a private
resolve(StyleValueHandle handle, float referenceLength)function toStyle.hthat resolves its property values directly fromStyleValueHandleand skips creating intermediate objects.I am aware that this duplicates the resolving functionality that already exists in
StyleLength.handStyleSizeLength.h, and may not be the cleanest solution. Optimization could go even further and totally drop theresolve()function fromStyleLength.handStyleSizeLength.h, and replace all usages with the newly introduced functions. But I think the performance boost is not high enough to justify that. Also it won't be the best API for Yoga library consumers - that's why I decided to keep them. However, I am opening this PR to start a discussion and would really like to hear opinions about it.Benchmarks:
Results were averaged over 20 runs.
This does not bring much gain in terms of performance when compared to the main branch.

However, it introduces a significant boost for the calc() and YGValueDynamic work.
Results before these optimizations:

And after:

cc @NickGerleman