-
Notifications
You must be signed in to change notification settings - Fork 25k
Implement VirtualViewContainerStateExperimental (interval tree, updateModes optimization) #54213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
|
@CalixTang has exported this pull request. If you are a Meta employee, you can view the originating Diff in D83783201. |
Summary: Introduces new React Native feature flag for VirtualViewContainerState versioning changes. Follow up diffs will create classic and experimental versions of VirtualViewContainerState. This feature flag is meant to eventually be overridden with MetaConfig variables. Differential Revision: D84569199
Summary: Removes unnecessary `debugLog` import in ReactVirtualViewExperimental and refactors the debug function Differential Revision: D84608555
…Android] Summary: Splits VirtualViewContainerState implementation into three parts: (1) an abstract parent class, (2) the "classic" version (existing version), and (3) the "experimental" version (new changes to be made). The experimental version is a copy of the classic version for now. Differential Revision: D84569206
CalixTang
added a commit
to CalixTang/react-native
that referenced
this pull request
Oct 20, 2025
…eModes optimization) (facebook#54213) Summary: Pull Request resolved: facebook#54213 ## Changelog: [Internal] Modifies `VirtualViewContainerStateExperimental` to use an interval tree to store the container's VirtualViews. Interval tree's query allows us to lower the frequently-used updateModes() operation from `O(n)` to `O(m + log n)`, where `m` is the number of VirtualViews in the hysteresis range. General layout changes incur a penalty due to the requirement of maintaining a balanced BST. Performance Changes: * updateModes(): `O(n) -> O(m + log n)` (new algo) * updateMode(): `O(1) -> O(1)` * add VV: `O(1) -> O(log n)` * update VV: `O(1) -> O(log n)` * delete VV: `O(1) -> O(log n)` We expect scrolling to be much more frequent than a total layout change/updating many of the elements in the container at once. However, the initial load of a page will take `O(n log n)` time rather than `O(n)` time. We also include some bookkeeping sets for "old" hysteresis, prerender, and visible VVs. This will increase the memory footprint of `VirtualViewContainerState` by `O(m)`. More details are in https://docs.google.com/document/d/1Cmamx6fNfruoHLApX8tedqNVZsCEUyoBvQWpMvBsfcY/edit?tab=t.gqla6vu3231k. ### Note This diff only covers the Android version. iOS may follow after experimentation. Reviewed By: lunaleaps Differential Revision: D83783201
a620a23 to
ce5537e
Compare
CalixTang
added a commit
to CalixTang/react-native
that referenced
this pull request
Oct 20, 2025
…eModes optimization) (facebook#54213) Summary: Pull Request resolved: facebook#54213 ## Changelog: [Internal] Modifies `VirtualViewContainerStateExperimental` to use an interval tree to store the container's VirtualViews. Interval tree's query allows us to lower the frequently-used updateModes() operation from `O(n)` to `O(m + log n)`, where `m` is the number of VirtualViews in the hysteresis range. General layout changes incur a penalty due to the requirement of maintaining a balanced BST. Performance Changes: * updateModes(): `O(n) -> O(m + log n)` (new algo) * updateMode(): `O(1) -> O(1)` * add VV: `O(1) -> O(log n)` * update VV: `O(1) -> O(log n)` * delete VV: `O(1) -> O(log n)` We expect scrolling to be much more frequent than a total layout change/updating many of the elements in the container at once. However, the initial load of a page will take `O(n log n)` time rather than `O(n)` time. We also include some bookkeeping sets for "old" hysteresis, prerender, and visible VVs. This will increase the memory footprint of `VirtualViewContainerState` by `O(m)`. More details are in https://docs.google.com/document/d/1Cmamx6fNfruoHLApX8tedqNVZsCEUyoBvQWpMvBsfcY/edit?tab=t.gqla6vu3231k. ### Note This diff only covers the Android version. iOS may follow after experimentation. Reviewed By: lunaleaps Differential Revision: D83783201
ce5537e to
a457dde
Compare
CalixTang
added a commit
to CalixTang/react-native
that referenced
this pull request
Oct 20, 2025
…eModes optimization) (facebook#54213) Summary: Pull Request resolved: facebook#54213 ## Changelog: [Internal] Modifies `VirtualViewContainerStateExperimental` to use an interval tree to store the container's VirtualViews. Interval tree's query allows us to lower the frequently-used updateModes() operation from `O(n)` to `O(m + log n)`, where `m` is the number of VirtualViews in the hysteresis range. General layout changes incur a penalty due to the requirement of maintaining a balanced BST. Performance Changes: * updateModes(): `O(n) -> O(m + log n)` (new algo) * updateMode(): `O(1) -> O(1)` * add VV: `O(1) -> O(log n)` * update VV: `O(1) -> O(log n)` * delete VV: `O(1) -> O(log n)` We expect scrolling to be much more frequent than a total layout change/updating many of the elements in the container at once. However, the initial load of a page will take `O(n log n)` time rather than `O(n)` time. We also include some bookkeeping sets for "old" hysteresis, prerender, and visible VVs. This will increase the memory footprint of `VirtualViewContainerState` by `O(m)`. More details are in https://docs.google.com/document/d/1Cmamx6fNfruoHLApX8tedqNVZsCEUyoBvQWpMvBsfcY/edit?tab=t.gqla6vu3231k. ### Note This diff only covers the Android version. iOS may follow after experimentation. Reviewed By: lunaleaps Differential Revision: D83783201
a457dde to
f685fe2
Compare
…eModes optimization) (facebook#54213) Summary: Pull Request resolved: facebook#54213 ## Changelog: [Internal] Modifies `VirtualViewContainerStateExperimental` to use an interval tree to store the container's VirtualViews. Interval tree's query allows us to lower the frequently-used updateModes() operation from `O(n)` to `O(m + log n)`, where `m` is the number of VirtualViews in the hysteresis range. General layout changes incur a penalty due to the requirement of maintaining a balanced BST. Performance Changes: * updateModes(): `O(n) -> O(m + log n)` (new algo) * updateMode(): `O(1) -> O(1)` * add VV: `O(1) -> O(log n)` * update VV: `O(1) -> O(log n)` * delete VV: `O(1) -> O(log n)` We expect scrolling to be much more frequent than a total layout change/updating many of the elements in the container at once. However, the initial load of a page will take `O(n log n)` time rather than `O(n)` time. We also include some bookkeeping sets for "old" hysteresis, prerender, and visible VVs. This will increase the memory footprint of `VirtualViewContainerState` by `O(m)`. More details are in https://docs.google.com/document/d/1Cmamx6fNfruoHLApX8tedqNVZsCEUyoBvQWpMvBsfcY/edit?tab=t.gqla6vu3231k. ### Note This diff only covers the Android version. iOS may follow after experimentation. Reviewed By: lunaleaps Differential Revision: D83783201
f685fe2 to
8df3b2c
Compare
|
This pull request has been merged in 328d07a. |
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.
fb-exported
Merged
This PR has been merged.
meta-exported
p: Facebook
Partner: Facebook
Partner
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:
Changelog: [Internal]
Modifies
VirtualViewContainerStateExperimentalto use an interval tree to store the container's VirtualViews. Interval tree's query allows us to lower the frequently-used updateModes() operation fromO(n)toO(m + log n), wheremis the number of VirtualViews in the hysteresis range. General layout changes incur a penalty due to the requirement of maintaining a balanced BST.Performance Changes:
O(n) -> O(m + log n)(new algo)O(1) -> O(1)O(1) -> O(log n)O(1) -> O(log n)O(1) -> O(log n)We expect scrolling to be much more frequent than a total layout change/updating many of the elements in the container at once. However, the initial load of a page will take
O(n log n)time rather thanO(n)time.We also include some bookkeeping sets for "old" hysteresis, prerender, and visible VVs. This will increase the memory footprint of
VirtualViewContainerStatebyO(m).Note
This diff only covers the Android version. iOS may follow after experimentation.
Reviewed By: lunaleaps
Differential Revision: D83783201