Repository navigation
Conversation
What a scrolled frame cost grew with the rows of the document, in three ways: - Culling looked at every row of a long column for the few near the viewport. A column whose children are one below the other is now noted with their tops, bottoms and which are made, kept while no op, layout or frame changes them, and only the rows within reach of the viewport and the made ones are looked at, found by binary search. - Each view made marked every overlay dirty, so with a hint in each row every frame worked out every hint's host. A view made or given up now queues the overlays in it alone, and what listens, keeps rows or orders Tab looks at the overlays in the view. - A row holding a hint not shown was never given up, so the made rows grew as the scroll went on. A hint not shown has no view to keep. A scrolled frame of 50,000 rows takes about 82 µs where it took about 1,200, and with a hint in each row about 150 µs where it took 21 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
💡 Strong perf change (50k rows: 1.2 ms → 82 µs per scrolled frame), but it is stacked on #4248 (base Reviewed head 6822c07 (diff read, partly).
|
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.
Stacked on #4248: the frames measured here are the ones that PR stopped laying out again. Retarget to
mainonce itmerges.
Summary
After #4248, the cost of a scrolled frame still grew with the number of rows in the document. There were three causes.
Culling walked the whole column (
core/cull.rs).sync_culled_inlooked at every child of a long column to findthe few near the viewport.
A column of at least 64 children placed one below the other is now noted as a
Column. Its children must be laid out,sized and in flow, with no transform, sticky, overlay or follower. The note holds the children's tops and bottoms and
the range that holds every made one. Culling then binary-searches the rows within reach of the viewport and also looks
at the made ones.
The note is kept while
cull_epochstays the same.cull_epochis raised by:Anything else falls back to walking every child.
Every view made dirtied every overlay (
core/overlay.rs).ensure_createdcalleddirty_overlays(), so with a hintin each row every scrolled frame sorted all overlays by depth and worked out every host again. Now:
queued).sync_overlaysworks out those hosts alone, outermost first. An overlay whose host changed queues the overlays in it.Every other change still dirties all of them, as before.
The listener lists,
overlay_scrolled,view_holders,sync_keptandorder_overlays_for_tabonly need shown orin-view overlays. They now walk
near, the overlays in the view, kept asin_viewchanges. They no longer walk everyoverlay.
Rows with a hidden hint were never given up.
reclaimablecounted any overlay in a subtree as a view to keep, shownor not. So rows with a hint stayed made, and the made rows grew as the scroll went on. An overlay with no view (a hint
not shown) no longer holds its row. When the row is made again, its hint's host is worked out again.
Public API
None.
Performance
cargo test --release -p nsh-core --lib bench_each_mount -- --ignored --nocapture(FakeEngine, 320 × 480, macOSarm64). Three alternating runs of this branch's test binary and #4248's (
9d574fccd). Values are µs per scrolled frame(20 points per frame, 200 frames):
eachAgainst
mainbefore #4248, the 50,000-row frame goes from 37–41 ms to 82 µs, and with a hint each from 73–75 ms to126–178 µs. The first mount and its 427 mount items are unchanged.
nsh test --trace:examples/counter/App.tsx(56 ops, 50 mount items) andexamples/bench/RowsTs.tsxscrolled3,000 pt and back (1,040 ops, 915 mount items) keep their counts.
examples/bench/jank/jank.py --runs 3on macOS, core: Lay nothing out again for text a scroll makes as it was estimated #4248 → this branch:The jank scene is short, so these differences are within run-to-run spread.
Content culling is on for iOS and Linux (GTK); the headless and native test drivers turn it off. This change is in the
platform-independent core, so the numbers above come from the core bench.
The record is in
docs/dev/performance.md.Tests
a_scroll_looks_at_the_rows_near_its_viewport_only: with and without a hint per row, 20 scrolled frames of 1,000 and4,000 rows. The children culling looks at plus the overlay hosts worked out must stay about the same. Without the
change they grow four times: 44,170 → 164,170 without hints, 68,220 → 248,220 with them.
rows_with_a_hint_not_shown_are_given_up_far_away: 2,000 rows with a hint each, scrolled 8,000 pt. Fewer than 400 rowsstay made, and
nearholds exactly their hints. Without the change, 563 stay made.Other checks:
cargo test -p nsh-core: all 2,162 tests pass.cargo test --workspace --no-fail-fastpasses exceptnsh-clia_built_record_survives_a_moved_home_and_a_new_timeand
nsh-platform-macosdraw_on_show, which fail onmaintoo.cargo clippy --workspace --all-targets: no new warnings.🤖 Generated with Claude Code