Skip to content

Build a Log row from fewer nodes - #41

Merged
simonhamp merged 5 commits into
mainfrom
perf/row-nodes
Oct 20, 2026
Merged

simonhamp merged 5 commits into
mainfrom
perf/row-nodes

Conversation

@simonhamp

@simonhamp simonhamp commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

On Simon's iPhone 16 Pro (Release) the long scroll stalls are mostly SwiftUI measuring and building Log rows as they scroll in: FlexContainer.sizeThatFits is about a third of them and row view-graph creation about a sixth. Every node in a row is another layout pass there, and more PHP render and serialise time here. Many of a row's nodes were wrappers that only padded or placed the one thing inside them, so this takes them out without changing how the row looks.

  • The row's pressable lays itself out as a row (flex-row) instead of holding one.
  • The 64pt rail gutter is the content column's left margin instead of an empty column, and the hairline is that column's bottom border, so the two nested columns become one. A border draws inside the box, so the bottom padding grows by the hairline's 1pt and the row stays the same height.
  • Each action button is the pressable itself. More keeps its inner column: a pressable with a menu draws its content as the menu's label at its own size, in the corner of the box (iOS and Android both), so the column is what centres the icon.
  • The rail positions the avatar's pressable, or the node itself, instead of wrapping it in a column just to place it.
  • The avatar ring is a lane border on a surface disc. A filled lane dot is a lane disc holding a lane centre with a 3pt surface border. One view fewer each.

Nodes per row, counted from the published frame in the test harness (Native::visit('/log')), against main as of #38:

Row Before After
Someone else's commit 39 30
Next in their run, 3 stars, 2 replies 41 31
Alone in its run (avatar and end dot) 43 32
Your own commit 39 30
Your own, next in the run 37 28

Depth goes from 8 to 6. A five-row Log frame goes from 328 nodes to 261. Three of each row's nodes are More's menu items, which aren't views.

Screenshots

iPhone 17 Pro simulator, iOS 27, both builds from the same native project and the same canned API, relaunched for each shot.

Pixel diff of the full-resolution screenshots: 142 to 459 pixels differ out of 3.2 million, none by more than 5.5%. All of them are where the rail line meets an avatar ring, where the ring's surface disc now anti-aliases over the line. I tried keeping the lane disc outside for avatars too, but then the avatar's wash and the gap's border share an edge and about 1,800 pixels change round every ring, so avatars keep the bordered surface disc. Dots keep the lane disc outside and come out identical.

Things to look at

  • Tests: CommitCardTest and QuoteTest read a button's tap target from the pressable now that there's no row inside it, and AccountProfileTest reads the ring colour from its border. A new CommitCardTest case checks the row's shape and that a row with stars and replies stays at 35 nodes or fewer (it was 47).
  • rail-node and rail-avatar take $position and $nodeRef rather than $class and $ref. Blade includes inherit the parent's variables, and rail-loading already has a $ref, so the rail would have given its end dot the skeleton's ref.
  • I only ran iOS. Android goes through the same paths (a pressable reads its own direction, margins become outer padding, per-side borders draw inside the box), but nobody has looked at it on a device or emulator.
  • Keep the Log's unchanged rows between renders #40 (merged) keeps unchanged rows between renders, so the two stack: fewer nodes per row and fewer rows rebuilt. The star is one flex-row pressable for everyone now that Replace saved bookmarks with starred commits #42 lets you star your own commits.
  • The screenshots were taken before main gained Replace saved bookmarks with starred commits #42, so your own commits there still show the old star count rather than a star button. Nothing else in the rows changed.
  • Not measured on the phone yet. The scroll-perf baseline to beat is 4.3 ms of main-thread work per ms of row building.

🤖 Generated with Claude Code

simonhamp and others added 5 commits October 20, 2026 15:18
A list builds and measures every node of a row as it scrolls in, and on
the phone that is most of what a scroll stall is. A plain commit row was
40 nodes, eight deep, many of them wrappers that only padded or placed
the one thing inside them. It is now 31, six deep, and looks the same.

- The row's pressable lays itself out as a row instead of holding one.
- The 64pt gutter is the content column's left margin, not an empty
  column, and the hairline is that column's bottom border, so the two
  nested columns are one. The bottom padding takes the hairline's 1pt.
- Each action button is the pressable itself, laid out as a row. More
  keeps its column, since a menu pressable draws its content at its own
  size in the corner of its box.
- The rail places the avatar's pressable, or the node itself, instead of
  wrapping it in a column to position it.
- The avatar ring is a lane border on a surface disc, and a filled dot is
  a lane centre with a 3pt surface border, each one view fewer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge with main kept main's star button, which still had a row
inside the pressable. Main now lets you star your own commits, so the
star-count row is gone and the star is one pressable for everyone. This
makes it a flex-row pressable like the other buttons, and keeps main's
updated logOf fixture in CommitCardTest with this branch's tap-target
lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main dropped Save commit from More, so the row in CommitCardTest is
47 nodes wrapped the old way and 35 flattened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonhamp
simonhamp merged commit 8ce7482 into main Oct 20, 2026
1 check passed
@simonhamp
simonhamp deleted the perf/row-nodes branch October 20, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant