Commit 328d07a
Implement VirtualViewContainerStateExperimental (interval tree, updateModes optimization) (#54213)
Summary:
Pull Request resolved: #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
fbshipit-source-id: 93a7a93784d668e09d8ddacc7e30d289ccd8b7a21 parent 793f99d commit 328d07a
File tree
2 files changed
+518
-56
lines changed- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll
2 files changed
+518
-56
lines changedLines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
114 | 153 | | |
115 | 154 | | |
116 | 155 | | |
| |||
0 commit comments