Avoid sticky header scans for non-sticky VirtualizedLists#57210
Open
tarikfp wants to merge 1 commit into
Open
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
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
VirtualizedList._createRenderMaskalways did the sticky-header lookup, even when there were no sticky headers. For a large list scrolled far from the top, that meant walking backward from the first visible item toward index 0 on every render-mask update.This changes that path to:
stickyHeaderIndicesis missing or emptyListHeaderComponentoffset handling and integer-index behaviorChangelog:
[GENERAL][CHANGED] - Speed up VirtualizedList render-mask creation for large lists by avoiding the old backward sticky-header scan when sticky headers are missing or sparse.
Affected components
This is inside
VirtualizedList, so the affected callers are:VirtualizedListFlatList, because it renders throughVirtualizedListVirtualizedSectionList/SectionList, because section lists also render through this pathstickyHeaderIndicesdoes not need to be set to get the no-sticky win. A normalFlatListwith no sticky headers still used to pay the backward scan. With this change, that case exits before the sticky-header helper runs.When
stickyHeaderIndicesis set, the lookup changes from scanning item indices back toward 0 to scanning only the sticky header index array. The size of the win then depends on how many sticky headers are configured.Benchmark
Benchmark command:
Fantom Hermes benchmark, 100 samples per case. Values below are median latency for
VirtualizedList._createRenderMaskwhen the viewport is near the end of the list.Per-call values are under 1 second, so they stay in milliseconds. For 1,000 render-mask updates, values over 1 second are shown in seconds.
This benchmark is intentionally focused on this helper. It does not claim the whole app or whole list render becomes thousands of times faster. It shows that this hot helper is no longer proportional to the scroll distance from the top of the list.
Test Plan:
Passed: 3 suites, 101 tests, 1 skipped, 76 snapshots.
Passed: 2 suites, 64 tests.
Passed: no errors.
Passed.
Passed.