Skip to content

Send only what changed on the timeline screens - #189

Draft
simonhamp wants to merge 11 commits into
perf/memo-timeline-rowsfrom
perf/partial-frames
Draft

simonhamp wants to merge 11 commits into
perf/memo-timeline-rowsfrom
perf/partial-frames

Conversation

@simonhamp

@simonhamp simonhamp commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Every timeline screen set $forceFullFrames, so each frame went to the phone whole: about 200 KB on a Log of 20 commits and 530 KB with 60, even for a star. This turns that off, one commit per screen, so any one can be reverted on its own.

This needs NativePHP/mobile-air#699 and NativePHP/mobile-air#730. On mobile-air 4.8.0 as this app locks it (c0da5d7), partial frames bring the blank Log back. In a scripted session on an iOS 27 simulator the reader met 261 reuse markers for nodes it never got: the Log went blank on Following and on Latest, and the commit page's thread went blank as soon as typing started. On an Android 15 emulator there were 266, and the Log went blank. With both PRs in vendor there were none on either. Merge this once composer.lock has a mobile-air with both. Until then the new tests skip themselves, so CI stays green on 4.8.0.

What changed

  • CachedRow sent a kept row in full every frame. It now builds the row against no hashes, so the kept node is always whole, and sends it the way EDGE's own walk does: a reuse marker for any part the phone holds by id and hash, the rest in full. Nothing changes while a screen keeps $forceFullFrames.
  • Then one commit per screen drops the flag: the Log, profiles, organizations, the commit page, Starred, Notifications, Remotes, Search and a Remotes thread. Each commit message says what that screen's blank case was and why it holds now.
  • No screen still needs full frames.

tests/Feature/Screens/PartialFramesTest.php replays every frame a screen publishes the way the phone's reader does, fails on a marker for a node the phone doesn't hold, and after each step checks the phone's tree against a full frame. Each screen's case walks through what used to draw it blank. Run against 4.8.0's PHP with the skip taken out, the Log, profile, organization, commit page and Remotes cases fail at their re-key steps (back to the top, a tab tapped again, the reply field). Starred, Notifications, Search and the thread pass there too: their blank lists came from the reader dropping frames, which only a phone shows.

Numbers

Same data and same build, before being $forceFullFrames switched back on at run time. Size is what the phone's reader got, and shadow thread is its parse and diff.

iOS 27 simulator, devnull's timing script, medians of 3 runs:

Step KB to the phone Shadow thread ms PHP ms, its own frame
Log, star a commit (20 commits) 863 → 40 32.4 → 3.2 7.1 → 6.3
Log, open a thread 496 → 58 16.0 → 1.5 23.3 → 23.6
Log, close the quote sheet 439 → 5 18.1 → 2.6 13.0 → 14.2
Log, next page at the end (60 commits) 562 → 185 16.3 → 3.0 49.9 → 46.2
Log, star with 60 commits 562 → 16 20.9 → 1.1 12.3 → 7.2
Profile, star a commit 830 → 40 32.1 → 2.6 9.8 → 7.1
Profile, swipe to Replies 415 → 180 11.3 → 2.9 34.2 → 37.1

A star is two frames, the star at once and then devnull's answer.

Mac, PHP only, the timeline bench from #187 (medians of 11 repetitions). KB is JSON of the frames published, and full is nodes sent in full rather than as markers:

Step PHP ms per step KB sent Nodes sent in full
log: star a commit 5.9 → 5.9 204.2 → 6.3 1048 → 11
log: open a thread 13.6 → 13.8 232.9 → 38.4 1209 → 189
log: open and close a sheet 9.7 → 9.4 416.0 → 10.3 2135 → 45
log: next page at the end 41.9 → 41.2 530.5 → 171.0 2730 → 856
log: star with 60 rows 7.0 → 7.2 530.5 → 9.2 2730 → 11
log: pull to refresh with 3 new on top 10.9 → 11.2 554.4 → 32.2 2855 → 136
log: back to top 19.5 → 17.0 554.4 → 518.2 2855 → 2666
log: delete from the middle 5.3 → 5.0 554.8 → 2.0 2857 → 6
profile commits: star a commit 7.8 → 7.8 174.0 → 6.3 931 → 12
org: star a commit 6.1 → 5.9 168.0 → 6.3 896 → 12
commit page: type a letter in the reply 6.2 → 6.0 55.4 → 4.3 302 → 18

On the Android 15 emulator, a star on the Log went from 7,568 nodes to 304 and its shadow thread time from 28 ms to 5, and a star with 60 commits from 2,763 nodes to 96 and 10 ms to 1 (logcat only gives whole milliseconds).

PHP time per frame doesn't change much: the rows were already kept (#187), and a marker costs about what a kept node did. The win is on the wire and on the phone's shadow thread, which drops from 16 to 32 ms a frame to 1 to 3 ms with the mobile-air PR's diff change. The main thread time didn't change measurably on the simulator.

Worth checking

  • A list re-keyed on purpose (back to the top, the new commits pill, a tab tapped again, a tap into the reply field) still goes out whole, because every row's id includes the list's key. That's the 518 KB back-to-top step above.
  • TestableComponent::tap() and assertSee() read the frame PHP built, which now has markers for unchanged rows. Only PartialFramesTest turns reuse on, so the rest of the suite is unaffected, but a future test that does needs call() to reach a row.
  • Device testing used Speed up the timeline's frames around its kept rows, and say why they aren't #[Memo] #187's bench harness with a faster torture script and a fake API, none of it in this PR. The kit is on the board.

Screenshots

  • No visible change

The screens draw the same. The torture runs above were checked in light and dark mode on both platforms.

🤖 Generated with Claude Code

simonhamp and others added 10 commits November 20, 2026 00:55
CachedRow sent its kept node in full every frame, so with EDGE's subtree
reuse on, a list whose rows are kept still went out whole whenever any
row changed. It now builds a row against no hashes, so the kept node is
always whole, and sends it the way EDGE's own walk sends a node: a reuse
marker for any part the phone holds by id and hash, the rest in full.

Nothing changes while a screen sets $forceFullFrames, because the hashes
start empty every frame there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Log sent every frame in full because EDGE's subtree reuse could refer
to rows the phone never got, which drew the list blank after a pull to
refresh. That is fixed in nativephp/mobile by NativePHP/mobile-air#699:
the reader parses every frame instead of dropping some, a row's id is
part of its hash, and a reader that still can't build a frame asks PHP
for a full one. With that, a star on a 60 commit Log sends about 9 KB
instead of 530 KB.

This needs that fix. On mobile-air 4.8.0 without it, the Log goes blank
again, so the new test skips itself there.

The test replays every frame the way the phone's reader does and checks
the result against a full frame after each step: a star, a thread, the
next page, new commits on top, back to the top, a delete from the middle,
the pill, the image viewer and a swipe to another log and back.

The other screens that set the flag no longer point at the Log's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A profile went in full so that a tab tapped again, which puts the same
rows in a list with a new key, still reached the phone. With a row's id
in its hash (NativePHP/mobile-air#699), the new list no longer matches
the old one, so it is sent as it should be.

The test covers a star, a thread, the tab tapped again, and a swipe to
Replies and back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An organization's page is built like a profile's and went in full for the
same reason: a tab tapped again puts the same rows in a list with a new
key. That reaches the phone now (NativePHP/mobile-air#699).

The test covers a star, a thread, the tab tapped again, and a swipe to
Mentions and back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tap into the reply field mounts the thread's scroll view again under a
new key, and subtree reuse then pointed at rows the phone had dropped, so
the thread went blank as you started typing. The new key now changes the
scroll view's hash (NativePHP/mobile-air#699), so it goes out whole, and
each letter typed after that sends only the reply bar.

The test opens the earlier commits and the replies, taps into the field
twice, and types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Starred went in full because rows leave its list from the middle. The
rows are keyed, so the frame after an unstar refers to the rows that
stay by id, and with the reader parsing every frame
(NativePHP/mobile-air#699) the phone has all of them.

The test unstars rows from the middle and the top, with a thread open
under one of them, and pulls to refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Notifications went in full for the same reason as the Log: subtree reuse
could refer to rows the phone never got and draw the list blank. Those
were frames the phone's reader dropped, which it no longer does
(NativePHP/mobile-air#699).

The test opens a group, brings two new notifications in on top, loads
the next page, closes the group and turns every kind back on, which puts
the list under a new key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remotes went in full because a conversation with a new message moves to
the top. Its rows are keyed, so the move refers to them by id, and the
tab tapped again now reaches the phone as a new list
(NativePHP/mobile-air#699).

The test moves two conversations to the top from the middle and lower
down, taps the tab again, swipes to Fetched and back, and checks the
order the phone ends up with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Search went in full because a new term replaces every row. New rows are
new ids, which go out in full anyway, and rows a term shares with the
last one are referred to by id, which the phone now always holds
(NativePHP/mobile-air#699).

The test picks a term, types more of it, switches to a term with the
same commits in another order, goes back, and clears the field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A thread went in full because messages come in at the bottom and their
reactions change in place. Both are ordinary changes to keyed rows, and
the frames that carried them are no longer dropped by the phone's reader
(NativePHP/mobile-air#699).

The test polls in a message and a reaction, types, hearts a message,
replies and sends, loads older messages above, and polls again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #178's HEAD@{last visit} band.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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