Repository navigation
Keep the Log's unchanged rows between renders - #40
Merged
Merged
Conversation
Every render of the Log built, serialised and published the whole list, so each page loaded made every later render slower. On an iPhone 16 Pro with OPcache a page-1 render took 50-90ms of PHP, and a few pages in it took 500-935ms, for every poll, event and load more. RowCache keeps each commit row and thread reply it drew last frame, hashed against its partial's data and the other things it shows (RowInputs: the viewer, pasteis mode, stashed drafts, unfolded and opened commits, relative times, poll status and which images are on the device). A row whose hash is unchanged is attached again instead of going through Blade. CachedRow sends its row's node in its place and keeps that node too, so toArray skips it as well while the row stays under the same keyed parent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Serializing every commit each frame was most of what a kept row still cost. The data objects are readonly, so RowCache keeps each one's hash in a WeakMap for as long as the object lives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp
added a commit
that referenced
this pull request
Oct 21, 2026
…49) The Log keeps the rows it drew last frame (RowCache, from #40), so a render only builds the rows that changed. Profiles, Starred and a commit's replies drew every row afresh on every render, so they got slower with every page they loaded, as the Log did. A profile keeps a cache per tab, Starred keeps one, and a thread keeps its replies. The commits above a thread's replies still build every time: they read what the screen shows of the thread, which the cache doesn't hash. The tab you're not on in a profile now previews three commits instead of five, as the Log's pages beside yours do. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
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.
Every render of the Log rebuilt the whole list in Blade, serialised it and published it, so each page you loaded made every later render slower. On Simon's iPhone 16 Pro (Release, OPcache PHP) a page-1 render was 50-90 ms of PHP, and a few pages in it was 500-935 ms. Polls, async completions, taps and load more all paid that.
This keeps the rows between renders.
RowCacheholds each commit row and thread reply the Log drew last frame, hashed against the partial's data and everything else the row shows (RowInputs). A row whose hash hasn't changed is attached again instead of going through Blade.CachedRowwraps it and sends the row's own node in its place, so the frame is byte for byte what it was, and it keeps that node too, so toArray skips the row as well while it stays under the same keyed list.It only uses EDGE's public pieces (
NativeElementCollector::capture()andattachElement(), plus an Element subclass), so it needs nothing new from mobile-air.Measured on Simon's iPhone 16 Pro, Release build with the OPcache PHP, scrolling the Following log by hand. Same build, cache switched off and on (the switch was a bench-only hook, not in this PR). Numbers are PHP time per render from EDGE's
PERFlines, render + toArray + publish.The rows with the cache are load-more renders, which build the 20 new rows. A quiet 30s poll at 220 commits now costs 93, 61 and 32 ms for its three renders, where each one was at least 443 ms before. toArray on a frame where nothing changed went from about 100 ms to 1-3 ms at 200 commits.
Without the cache PHP stopped answering at 360 commits (looks like it runs out of memory and never recovers). That's for a separate change. With the cache the frame is the same size, so it doesn't fix that.
Locally, with 20 made-up commits a page on PHP 8.4 with OPcache on a Mac,: at 8 pages a render went from about 140 ms + 47 ms toArray to 8 ms + 1 ms.
What to watch for:
RowInputshas to cover everything a row partial reads from the screen, the clock or the device. Today that's the viewer, pastéis mode, stashed drafts, unfolded and opened commits, relative times, poll status, and which avatars and images are already downloaded. A partial that starts reading something new needs adding there, or its row keeps showing the old thing. The first test inLogRowCacheTestwalks through each of those changes and checks the kept frame against one built from scratch; taking any of them out ofRowInputsmakes it fail, except the opened-thread flag, whichthreadBelowhappens to cover in that fixture.feedwithout a$rowCache.Other options I looked at:
NPHP_FLAG_VIRTUALIZEis only a reserved bit in php-bin-mobile, nothing reads it. mobile-ui's<native:virtual-list>draws fixed-height grey boxes outside its window and has no pull to refresh, end-reached or variable row heights.$forceFullFrames. Blade still renders every row and toArray still hashes every node, so it would only save the publish, about 3% of the time.🤖 Generated with Claude Code