Conversation
`ShadowNode::cloneTree` and `UIManager::updateShadowTree` copy the parent's children into a local vector, replace the updated child, and then copy that local again into the `std::make_shared` passed to `clone`. The second copy bumps and drops the refcount of every sibling. The local is dead after the call, so move it instead. `addAncestorsToUpdateList` also copied the whole children vector just to read a single element; take it by reference. Added `cloneTree` coverage to `ShadowNodeTest`. Changelog: [General][Changed] - Avoid a redundant copy of the children list in `ShadowNode::cloneTree` and `UIManager::updateShadowTree` Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this in D122059304. |
This branch has not been deployed
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:
ShadowNode::cloneTreecopies the parent's children into a local vector, swaps in the new child, then copies that local again into thestd::make_sharedpassed toclone(). The second copy bumps and drops the refcount of every sibling at each level on the path to the root. The local is dead after the call, so this moves it instead.UIManager::updateShadowTreehas the same double copy, andaddAncestorsToUpdateListcopied the whole children vector just to read one element. Output is unchanged.This is a small cleanup rather than a meaningful perf win, since the parent clone itself does O(N) Yoga work per child. Host benchmark (clang -O3, Apple M4 Pro),
cloneTreeon one leaf of a View with N View siblings, median of 7 runs:At 10–100 children the difference is within noise.
Benchmark
Changelog:
[GENERAL] [CHANGED] - Avoid a redundant copy of the children list in
ShadowNode::cloneTreeandUIManager::updateShadowTreeTest Plan:
Added
cloneTreecoverage toShadowNodeTest. Built the renderer gtests on the host with CMake (Debug):core/tests: 65/65 pass (the 4 Hermes-dependent files were not built)mounting/testsStateReconciliationTest, StackingContextTest, OrderIndexTest: 21/21 passNot built for Android/iOS and not measured on a device.
🤖 Generated with Claude Code