Skip to content

build(bench): measure seeded client navigation and streaming - #415

Merged
nixuuu merged 1 commit into
perf/client-2from
perf/client-3
Nov 9, 2026
Merged

nixuuu merged 1 commit into
perf/client-2from
perf/client-3

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Rebase verification — 2026-11-09

The five-layer stack is rebased onto dev at 2580ed75cdfc162e98e125b7c4d0b24eb81901b7, including #418 and #421–#426. All PRs remain ready for review. The measurements below describe the original baseline; this section records the current integration verification.

The attachment route now passes If-None-Match through #421's shared response helper. Gateway authorization/read succeeds before a 304 is possible; qualified IDs, thumbnail fallback, bounded preview/truncation, sanitized public failures and no-store errors are retained. Mobile image caching retains public error messages and reconnect retries. Session startup, replacement pairing, unpair and revocation retain all four caches: transcript, bot, archived sidebar and images. The branch/worktree panel, channel identity and sheet gesture changes remain intact.

Passed on the rebased top branch: bun install, bun run gen:check, full bun run typecheck, root bun run lint, bun run format:check and the production web build. Final focused check:tmp: 27 passed, 0 failed, 334 assertions across 7 files, no temp leftovers (images, immutable HTTP, transcript/archive/bot caches, two-gateway linked previews and composer choices). Coverage includes a matching old ETag returning 404 after ownership changes and 409 while the home is unavailable, with no-store and no ETag; image/archive caches are wiped together and late callbacks cannot restore them.

EAS CLI 27.4.1, production profile, before/after the image-cache and preparation layers and on the final top branch: unchanged relative to the latest dev baseline:

  • iOS: bf3156a1bd878e10c0b0be25d4c194a837fb1b7e
  • Android: d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae

These differ from the original measurement hashes below because #424 already changed native branding/configuration on dev. This stack adds no native dependency/configuration change. Final production Hermes exports passed sequentially with one Metro worker: iOS 9,971,620 B, Android 9,961,323 B. These include the newly merged client features; the earlier performance comparisons below retain their original baseline. Expo Doctor: 20/20. An additional Expo ESLint check of the conflict files reports the same pre-existing react-hooks/set-state-in-effect finding in useImage.ts on both this head and unmodified origin/dev; session cleanup has no Expo ESLint findings. The required root oxlint check passes.

No full local test run was started, as requested for the overloaded shared machine. The earlier full-run timeout below is historical; GitHub CI is the current full-suite merge gate. No native builds, EAS builds, OTA publication or UI test suites were added. Previous on-device profiling gaps remain.


Adds synthetic seeded data and a scripted worker so client measurements can use a real gateway/BFF/EventSource path without inference or an existing developer stack. The worker only produces synthetic answers; credentials stay in process memory. Scripts clean up their own servers/container and require a disk-backed TMPDIR.

Metric / coverage Before After Method / environment
Private database dataset Empty 500 threads; one with 1,000 turns and 7,099 items New disposable PostgreSQL only
Very long single answer Moderate fixture answers Last answer repeated 64 times; configurable 1–100 in dev fixture answerRepeat=64
Streaming producer In-process synthetic updates 200 deltas at 25/s over worker → gateway → BFF → SSE Scripted worker, no CLI/model
Snapshot handler coverage JSON-object decoder/reducer Actual EventSource arrival + string JSON parse + protobuf decode + state apply probeThreadSnapshot(id,20)
Navigation coverage Renderer remount SPA thread paint/focus-ready proxy probeThreadNavigation(path)
Bundle attribution SvelteKit node numbers Route names, all layouts, shell and deduplicated JS/CSS closure Generated SvelteKit manifests

probeThreadStream(id) sends a message and is intended exclusively for the disposable synthetic thread. Both probes request incremental SSE, ignore heartbeat frames when waiting for the first snapshot, and stream completion follows the submitted turn's terminal state (including coalesced updates). The seed gives threads a provider session identity so submitted turns can start. BFF coalescing reduces the number of delivered messages. Handler timing excludes rendering; the normal thread page can remain subscribed to inspect the same stream. A sampled run delivered 49 coalesced delta messages in 8.10 seconds, with handler median / p95 of 0.2 / 0.3 ms on Chromium 156, Linux x86_64, 1280×800. It generated 200 producer deltas at 25/s without inference.

This layer adds measurement coverage, not a production performance claim. Navigation paint/focus readiness is not browser TTI. Cold FCP depends on build/cache state. Native render counts, native UI frames, filesystem latency and image bitmap memory still require an on-device profile. No UI test suite was added. Polish docs/client-performance.md documents commands and limits; whole-stack verification and measured browser results are recorded on the top PR.

Fresh-launch verification after the tooling correction: a newly created disposable database and production BFF accepted one synthetic message, delivered 45 coalesced itemDelta events plus itemCompleted / turnFinished, and persisted the turn as completed. No manual database updates were needed. The bounded SSE capture intentionally stopped at its 15-second curl deadline after completion; that deadline is not a stream failure.

@nixuuu
nixuuu added this pull request to stack #417 November 9, 2026 14:41
@nixuuu
nixuuu removed this pull request from stack #417 November 9, 2026 16:04
@nixuuu
nixuuu added this pull request to stack #420 November 9, 2026 16:04
@nixuuu
nixuuu force-pushed the perf/client-3 branch 2 times, most recently from 305cac5 to f0bddfe Compare November 9, 2026 16:50
@nixuuu
nixuuu marked this pull request as ready for review November 9, 2026 16:54
@nixuuu
nixuuu merged commit 26c4348 into dev Nov 9, 2026
19 of 24 checks passed
@nixuuu
nixuuu deleted the perf/client-3 branch November 9, 2026 17:31
nixuuu added a commit that referenced this pull request Nov 9, 2026
### Rebase verification — 2026-11-09

The five-layer stack is rebased onto `dev` at
`2580ed75cdfc162e98e125b7c4d0b24eb81901b7`, including #418 and
#421–#426. All PRs remain ready for review. The measurements below
describe the original baseline; this section records the current
integration verification.

The attachment route now passes `If-None-Match` through #421's shared
response helper. Gateway authorization/read succeeds before a 304 is
possible; qualified IDs, thumbnail fallback, bounded preview/truncation,
sanitized public failures and `no-store` errors are retained. Mobile
image caching retains public error messages and reconnect retries.
Session startup, replacement pairing, unpair and revocation retain all
four caches: transcript, bot, archived sidebar and images. The
branch/worktree panel, channel identity and sheet gesture changes remain
intact.

Passed on the rebased top branch: `bun install`, `bun run gen:check`,
full `bun run typecheck`, root `bun run lint`, `bun run format:check`
and the production web build. Final focused `check:tmp`: **27 passed, 0
failed, 334 assertions across 7 files**, no temp leftovers (images,
immutable HTTP, transcript/archive/bot caches, two-gateway linked
previews and composer choices). Coverage includes a matching old ETag
returning 404 after ownership changes and 409 while the home is
unavailable, with `no-store` and no ETag; image/archive caches are wiped
together and late callbacks cannot restore them.

EAS CLI **27.4.1**, production profile, before/after the image-cache and
preparation layers and on the final top branch: **unchanged relative to
the latest dev baseline**:

- iOS: `bf3156a1bd878e10c0b0be25d4c194a837fb1b7e`
- Android: `d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae`

These differ from the original measurement hashes below because #424
already changed native branding/configuration on dev. This stack adds no
native dependency/configuration change. Final production Hermes exports
passed sequentially with one Metro worker: iOS **9,971,620 B**, Android
**9,961,323 B**. These include the newly merged client features; the
earlier performance comparisons below retain their original baseline.
Expo Doctor: **20/20**. An additional Expo ESLint check of the conflict
files reports the same pre-existing `react-hooks/set-state-in-effect`
finding in `useImage.ts` on both this head and unmodified `origin/dev`;
session cleanup has no Expo ESLint findings. The required root oxlint
check passes.

No full local test run was started, as requested for the overloaded
shared machine. The earlier full-run timeout below is historical;
**GitHub CI is the current full-suite merge gate**. No native builds,
EAS builds, OTA publication or UI test suites were added. Previous
on-device profiling gaps remain.

---

Obrazy mobilne są pobierane dopiero po wejściu do widocznego okna osi
czasu. Powrót do historii lub otwarcie viewerów korzysta z prywatnych,
niezmiennych plików zamiast ponownego RPC i base64.

Cache rozdziela parowania (owner-bound device id + pin), pełne
kwalifikowane identyfikatory komputerów i rzeczywiste warianty
thumbnail/full. Blob lub załącznik bez miniatury dzieli pełny wariant
pomiędzy listą i viewerem, bez powtórnego odczytu. Pliki i katalogi mają
nazwy SHA256; limit dysku to 200 MiB / 2048 wpisów, indeks URI w pamięci
ma budżet 24 MiB ważony bajtami obrazu. To nie ogranicza natywnych
bitmap. Wspólne żądania są anulowane po odejściu ostatniego odbiorcy.
Forget, revocation i ponowne parowanie zamykają cache i usuwają pliki;
spóźniona odpowiedź nie odtwarza danych. Brak nowych modułów natywnych
lub uprawnień galerii.

Załączniki w listach i wysłane chipy używają miniatur; viewer pełnego
wariantu. GetThreadBlob nie udostępnia miniatur: jego podglądy nadal
używają obrazu źródłowego. BFF zachowuje private/immutable, dodaje ETag
SHA256 reprezentacji i 304 po autoryzacji; błędy API mają no-store.
Istniejące loading="lazy" i odrębne URL ?thumbnail/?preview pozostają
zachowane. Zmiana nie ingeruje w routing linked previews 409.

| Metryka | Przed | Po | Metoda / środowisko |
|---|---:|---:|---|
| Żądania: 20 miniatur, dwa przejścia + ponowne otwarcie | 60 | 20 | bun
scripts/bench/image-cache.ts, Bun 1.4.4 Linux; symulowane montowania,
rzeczywisty HTTP + filesystem |
| Bajty odpowiedzi | 983 040 | 327 680 | 20 deterministycznych miniatur
po 16 KiB, ten sam scenariusz |
| Restart cache / ponowne otwarcie, to samo parowanie | 20 / 327 680 B |
0 / 0 B | nowa instancja cache, zachowany prywatny dysk |
| Fingerprint iOS | 2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3 |
identyczny | eas-cli 27.4.1, production, przed/po |
| Fingerprint Android | c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d |
identyczny | eas-cli 27.4.1, production, przed/po |
| Bundle Hermes iOS, cały stos względem pierwotnego dev | 9 900 217 B |
9 927 705 B | expo export, produkcyjny JS/assets, bez builda natywnego |
| Bundle Hermes Android, cały stos względem pierwotnego dev | 9 889 662
B | 9 917 398 B | expo export, produkcyjny JS/assets, bez builda
natywnego |

Rzeczywista przeglądarka Chromium 156, produkcyjny BFF + gateway,
prywatny seed 1000 tur / 500 wątków, 1280×800: 20 PNG 256×256 w dwóch
wiadomościach. Pierwsze przejście pobrało 20 miniatur / 803 816 B treści
(809 816 B Resource Timing transferSize). Drugie przejście: 0 żądań
sieciowych / 0 B; ponowne otwarcie: 0 / 0 B, 20 wpisów z cache. Web już
miał private/immutable, więc nie przypisujemy tej zmianie oszczędności
ponownego transferu w web. To pomiar po zmianie; historycznego before w
browserze dla obrazów nie zarejestrowano. Seed tego przebiegu miał
ręcznie uzupełniony katalog załączników workera; narzędzie w #415 teraz
zgłasza go przy hello.

Browser potwierdził: loading="lazy", ?thumbnail, różne ETag dla
thumbnail/full/preview, 304 z poprawnym If-None-Match i 404 z no-store
bez ETag. Sprawdzono telefon 390×844 w dark i desktop 1280×800 w light;
bez poziomego overflow, obrazy poprawnie zdekodowane. Serwery i browser
zamknięte przed pełnymi testami.

Weryfikacja: install, gen:check, pełny typecheck, root lint,
format:check, web build i eksporty Expo obu platform przeszły. Expo
Doctor: 20/20 kontroli. Końcowe 5 testów cache/HTTP (39 asercji)
obejmuje izolację, restart, LRU, brak pliku po usunięciu przez OS,
retry, współbieżność, ponowne użycie pełnego wariantu i wipe przy późnej
odpowiedzi; przeszły również w pełnym przebiegu. Dodatkowy Expo ESLint
dla zmienionych plików wskazuje istniejące już set-state-in-effect w
useImage; nowe wskazania refs zostały poprawione i sprawdzone ponownie.

Pierwotny końcowy pełny check:tmp zakończył się 1919 pass / 161 skip / 1
fail, 22 240 asercji, 1050.58 s, bez pozostałości temp. Pozostał
niezmieniany test composer-shell „Stop during a shell steer kills its
group and persists the failed delivery” — anulowanie RPC po 10 s.
Wcześniejszy przebieg miał też błędy ask-user i thread-mirror-deltas;
wszystkie trzy pliki przeszły następnie osobno razem (42 pass / 0 fail,
226 asercji, 38.70 s). Nie zmieniano timeoutów ani asercji. W pierwotnym
przekazaniu pełna bramka pozostawała nierozstrzygnięta, a stos był
draftem.

Harness nie mierzy renderera React Native ani RPC. Na urządzeniu
pozostają: widoczność wewnątrz wysokiej tury, szybki scroll/anulowanie,
bitmapy i filesystem Expo, viewer/restart/unpair/revocation; instrukcje
w docs/client-performance.md. Brak buildów natywnych, EAS i publikacji
OTA. Copy audit: bez nowych tekstów UI.
nixuuu added a commit that referenced this pull request Nov 10, 2026
Busy threads used to repaint shimmering labels and synchronously measure
the virtual feed while streaming. Running-work decorations now use
compositor transforms/opacity, visible elapsed labels share one clock,
and unchanged history/indexes stay out of the streaming update path. The
soft highlight, spinners, durations, disclosure motion and
reduced-motion behavior are preserved.

### Changes

- Replace background-position shimmer with a static text raster, a
translating soft mask and counter-translating highlight. Chromium
identifies both layers as active accelerated transform animations; no
blanket `will-change`.
- Share elapsed/relative clocks; second ticks update only a text
component. One IntersectionObserver pauses clocks/decorations outside
the viewport and document visibility stops hidden-page work. Mobile uses
foreground/viewport guards, one elapsed clock and non-interactive native
animation loops.
- Cache independent completed feed prefixes with conservative
invalidation for edits, late results/notices, fold preferences, nesting
and cross-turn background work. Retain structural row metadata so text
deltas do not rebuild size indexes/entrances.
- Batch clipped-text reads, retain motion tokens until root appearance
changes, and let ResizeObserver handle content growth instead of forcing
scrollHeight reads on every delta. Contain layout/style in virtual rows
and layout/paint in capped code surfaces.
- Add Polish rules to `docs/client-performance.md` and pure data/index
regression coverage. No UI test suite or diagnostic artifacts are
committed.

### Maintainer trace

Read-only analysis of the supplied 20.254 s trace (120 Hz recording):

| Event | Count | Main-thread time |
| --- | ---: | ---: |
| Style recalculation | 2,271 | 4,528.43 ms |
| Layout | 273 | 142.18 ms |
| Paint | 2,108 | 404.09 ms |
| Pre-paint | 2,397 | 999.48 ms |
| Layerize | 1,874 | 1,077.97 ms |
| Commit | 1,875 | 168.06 ms |

1. Renderer main was busy **49.94%** of the recording. There were **27
long tasks** (79.98/min), maximum **213.57 ms**, and **557/2,431
dropped-frame deadline markers (22.91%)**. The recording is 120 Hz;
these are not 60 Hz rAF estimates.
2. Long-task self samples point to `VirtualFeed.svelte/settle` (`Me`,
`n4KsTDu5.js:42:17016`, approximately **931 ms**), native
`getPropertyValue` under `motion.ts/rootToken` (**650 ms**),
`AgentMessageBubble.svelte`'s resize measurement (`n4KsTDu5.js:3:1049`,
**224 ms**), native `offsetWidth` (**165 ms**) and `clipped.ts/measure`
(`B-CkncHS.js:1:286`, **127 ms**). Embedded compiled source was read to
map these sites. Sample weights are estimates, not additive inclusive
timings. **206 invalidation-followed-by-script layouts** cost **122.08
ms**; **36 tasks** contained multiple layouts.
3. The original CSS shimmer animates background-position and needs
main-thread paint. Repeated animation observations include **916
transform-acceleration failure flags** (763 × 1024 and 153 × 132096),
**38 moving-pixel filter flags** (4096), and **15 observations with the
unsupported-CSS-property bit** (8192). These are state observations, not
distinct animations. A partial start record identifies an
`ARTICLE.t-unfold`; without a complete DOM/CSS snapshot and starts for
pre-existing animations, the full target inventory and `will-change`
count cannot be recovered. The live baseline inventory below supplies
steady counts. Spins/pings use CSS transforms/opacity; there is no JS
spinner rAF loop in the inspected components. Flag meanings follow
Chromium's `CompositorAnimations::FailureReason` enum;
unidentified/one-shot effects are not assumed to be the shimmer.
4. **11 newly installed one-second repeating fold timers**, **30
token-cache rAF requests**, and **225 rAF callbacks / 460.64 ms** occur
in the trace. Some persistent timers were installed before recording.
Code inspection confirms per-fold/per-background-task one-second clocks
and a shared slower relative clock. The synthetic trace additionally
exposes whole-history rebuilding per delta: long-task self samples
include **887 ms** of feed shallow comparison, **597 ms** of row
reconstruction and **505 ms** in `buildTimeline`, besides **1,219 ms**
in `settle`.
5. GC is secondary in the maintainer recording: **19 top-level pauses /
56.82 ms**, largest **10.53 ms**. Used JS heap grows **53.62 → 66.13
MB** (peak **78.61 MB**); DOM counters include detached nodes and do not
prove a leak. The supplied recording has frame markers and renderer
Layerize/Commit, but no timed compositor/Viz draw stages recognized by
the analyser; GPU/compositor totals are unavailable, not zero. The local
trace separately records compositor prepare/draw and Viz draw time,
which must not be added to nested main-thread stages.

### Reproducible comparison

Linux / AMD Ryzen 5 5600X / Chromium 155 / Bun 1.4.4; 1512 × 949, dark
theme, warm Vite fixture. Baseline is
`8b6492d84a0c38e4df08f0d6b2e344e99cc4439c`. Both runs load all 1,000
turns, four expanded running subagents and their tray, six running
sidebar rows alongside the seeded 500-thread sidebar, four elapsed
headers, and four expanded commands. A 40 ms interval applies an agent
text delta plus a round-robin tool-output delta through the real
ThreadState and production components. Requested load is identical; an
overloaded baseline delivers fewer ticks. No builds/checks ran alongside
these two-minute recordings.

| Metric | Before | After |
| --- | ---: | ---: |
| Recorded window | 120.035 s | 120.022 s |
| Main-thread busy | 97.26% | **54.17%** |
| Long tasks/min (> 50 ms) | 77.48 (155 total) | **2.00 (4 total)** |
| Dropped-frame deadlines | 39.91% (2,874/7,202) | **4.86% (350/7,202)**
|
| Average rAF frame gap | 27.85 ms | **16.72 ms** |
| p95 rAF frame gap | 50.10 ms | **16.70 ms** |
| Style + layout / second | 113.44 ms | 115.33 ms |
| Delivered streaming ticks (target 25/s) | 2,546 (21.21/s) | **2,998
(24.98/s)** |
| Style + layout / delivered tick | 5.35 ms | **4.62 ms** |
| Script-forced layouts | 2,586 / 8,971 ms | **35 / 32.39 ms** |
| Paint time | 20,880 ms | **16,426 ms** |
| GC pauses | 655 / 1,911 ms | **121 / 255 ms** |
| Trace used heap, first → last | 113.49 → 340.67 MB | **129.27 → 134.03
MB** |
| Trace peak used heap | 482.86 MB | **201.96 MB** |
| Follow-end gap after two minutes | 0 px | **0 px** |

The after run processes **17.8% more streaming ticks**. Absolute
style/layout per second is essentially unchanged; cost per delivered
update is lower. **The stressed developer build is still 54% busy and
misses about 5% of compositor deadlines, so this does not demonstrate
fully idle main-thread usage or flawless 60 fps.** It removes sustained
rAF jank and most long tasks while preserving follow-end. The remaining
cost includes growing output layout/paint, the real sidebar feed and
tracing/dev instrumentation.

Busy % is the union of renderer-main RunTask wall intervals inside
explicit measurement marks. Long tasks are RunTask > 50 ms; dropped %
counts trace BeginFrame/DroppedFrame deadlines. Average frame gap comes
from rAF, not compositor presentation. Heap is used heap, not retained
heap after GC; it includes a growing transcript and dev tooling, so
these readings do not establish a leak. This synthetic Linux developer
build is not a repeat of the maintainer's macOS desktop workload.

The steady live baseline has **23 CSS animations** (5
background-position shimmers, 14 spins, 4 pings), versus **28** after
(the 5 shimmers each use two transforms, plus the same spins/pings).
There are **0 transitions and 0 `will-change` elements** in both steady
inventories. The inspected after shimmer/spinner layers report **“Has an
active accelerated transform animation or transition.”** Paused
offscreen nodes remain mounted and can retain a layer, but their
animations stop advancing. An isolated five-second decoration/clock
recording paints only **0.51 ms total**, with no dropped deadlines; it
includes the still-connected dev application and is not a clean CPU-idle
benchmark.

The after browser run checks that it starts at the end, then records **0
px end gap** and **0 px reader-anchor drift** during a subsequent
three-second stream after a real wheel gesture. Light/dark, 1512 px
desktop and 390 px phone screenshots, long-label truncation, offscreen
pause and reduced motion were inspected. Headless Chromium kept both
tabs visible: hidden-page lifecycle was verified with a simulated
`document.hidden`/visibility event, and the clock did not advance until
resume. Native mobile visuals/runtime profiling and the macOS Electron
renderer were not run.

### Validation

- `bun install`; `bun run typecheck`; `bun run lint`; `bun run
format:check`; `bun run --filter @canopy/web build` — passed.
- `bun test apps/web/test/feed-prefix.test.ts
apps/web/test/feed-rows.test.ts apps/web/test/work-fold-state.test.ts` —
**12 passed, 82 assertions**. These exercise pure feed/index state, not
UI components. No UI/E2E suite or full integration/temp suite was run.
- iOS and Android JS/Hermes exports — passed. Native project
generation/build/publication was not performed.
- `bunx [email protected] fingerprint:generate --platform <ios|android>
--build-profile production --json --non-interactive` — before/after
identical: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`; Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`.

Copy audit (§8): visible copy is unchanged (`Working`, `Working for …`,
`Thinking`, durations and unavailable-time placeholders). Existing
duration accessibility labels and truncation are retained. Checked
short/typical/long labels at desktop and phone widths in light/dark. No
new glossary terms, controls, errors or empty states.

Artifacts are outside the repository in `/var/tmp/canopy-anim-perf/`:
`analyse.py`, `measure.mjs`, `qa.mjs`, `fixture.patch`,
`maintainer-report.json`,
`before-final-{trace,report,metrics,inventory,layers}.json`,
`verified-final-{trace,report,metrics,inventory,layers,anchor}.json`,
`isolated-animations-{trace,report}.json`, `qa.json`, screenshots and
check logs. Earlier exploratory traces are retained separately; the
table uses only `before-final` and `verified-final`. The scratch runner
temporarily exposes the fixture ThreadState using `fixture.patch`; that
exposure is removed from the submitted code. The analyser reconstructs
X/B/E spans, merges nested timing intervals, samples ProfileChunks,
correlates invalidations/script layouts, inventories timer/rAF callers
and extracts embedded source text without executing it.

Related: #413, #414, #415, #416, #417, #418, #419
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