Notes Float: trim first-paint JS (phone stack as its own chunk): index 238.33 -> 231.76 KB brotli #1142

Closed
kayg wants to merge 0 commits from port/notes-float-trim into port/notes-float
Owner

First-paint JS on port/notes-float @ 6a3ef2e83 was 238.3 KB brotli (line 240). This takes it to 231.76 KB (-6.57 KB), first CSS 21.4 -> 18.98 KB. No feature dropped, first frame unchanged. Evidence in the comments below.

What moved: the phone push stack (PhoneStack and what only it uses: the places list Sidebar.svelte, note cards, phone-only helpers) is its own lazy chunk (PhoneStack, 8.57 KB). A wide screen's first paint no longer carries it.

  • main.ts starts the chunk fetch at the very top on a phone, in parallel with fonts, the prefs read and the session check, and the first frame waits for it (holdStartup retry path as for sign-in). So a phone paints at the same moment as before.
  • A wide screen fetches it at idle (after first paint, same moment as warmUI), so narrowing a window to phone width draws the stack at once (Safari: 63-80 ms either way, equal to base).
  • App.svelte renders it through lazy(); a window narrowed after load loads it on demand if idle has not run yet.

What I looked at and did NOT move (first-frame risk or too small for the risk): behind-glass (9 KB raw, registers at the first glass and sets the inks), LibraryTab/AppSwitch/Selector (first frame of the window), tag drag (arrange-drag + tree-arrange = 2.2 KB raw: the drag state is wired into the row's pointerdown, a lazy load there would delay pickup), all-apps (0.3 KB), wipe (already split in trim round 1), the editor (the first note).
Note: the 240 line counts only what the HTML loads, so phones still download the stack chunk before their first frame; it is just not in the desktop first paint any more.

Budgets: index 231.88, first css 19.0, PhoneStack 8.6, and two small chunks the split made (PageToolbar 0.85, panes 1.43: shared by the stack and by Shell's lazy toolbar); every other chunk line set to its measured size (hash jitter, up to +0.1); total = sum.

First-paint JS on `port/notes-float` @ 6a3ef2e83 was 238.3 KB brotli (line 240). This takes it to **231.76 KB** (-6.57 KB), first CSS 21.4 -> 18.98 KB. No feature dropped, first frame unchanged. Evidence in the comments below. **What moved:** the phone push stack (`PhoneStack` and what only it uses: the places list `Sidebar.svelte`, note cards, phone-only helpers) is its own lazy chunk (`PhoneStack`, 8.57 KB). A wide screen's first paint no longer carries it. - `main.ts` starts the chunk fetch at the very top on a phone, in parallel with fonts, the prefs read and the session check, and the first frame waits for it (`holdStartup` retry path as for sign-in). So a phone paints at the same moment as before. - A wide screen fetches it at idle (after first paint, same moment as `warmUI`), so narrowing a window to phone width draws the stack at once (Safari: 63-80 ms either way, equal to base). - `App.svelte` renders it through `lazy()`; a window narrowed after load loads it on demand if idle has not run yet. What I looked at and did NOT move (first-frame risk or too small for the risk): `behind-glass` (9 KB raw, registers at the first glass and sets the inks), `LibraryTab`/`AppSwitch`/`Selector` (first frame of the window), tag drag (`arrange-drag` + `tree-arrange` = 2.2 KB raw: the drag state is wired into the row's pointerdown, a lazy load there would delay pickup), `all-apps` (0.3 KB), `wipe` (already split in trim round 1), the editor (the first note). Note: the 240 line counts only what the HTML loads, so phones still download the stack chunk before their first frame; it is just not in the desktop first paint any more. Budgets: index 231.88, first css 19.0, `PhoneStack` 8.6, and two small chunks the split made (`PageToolbar` 0.85, `panes` 1.43: shared by the stack and by Shell's lazy toolbar); every other chunk line set to its measured size (hash jitter, up to +0.1); total = sum.
Author
Owner

Evidence (head aa107415c; dev-01 x86 + dev-02 aarch64, same toolchain; PR #1142)

What Notes Float added to the index chunk (per-module generated bytes from the sourcemap, 6a3ef2e83 vs dev 6c50dd99c, raw; 46.5 KB raw = ~13 KB brotli): behind-glass 9.1 K, LibraryTab 6.2 K, Selector 3.6 K, AppSwitch 3.6 K, WindowLayout 3.6 K, behind.ts 2.0 K, app-swipe 2.0 K, TreeRow 1.8 K, NotesSide 1.7 K, arrange-drag 1.4 K, page-style 1.3 K, Shell +1.2 K, glass-rules 1.2 K, GlobalLayer 1.1 K, idle-rows 1.1 K, Tabs +1.1 K, tag-tree 1.0 K, tree-arrange 0.9 K, custom-backdrop 0.9 K, SideTabs 0.7 K, WindowDock 0.6 K, the rest under 0.6 K each. Almost all of it is the first frame of the window; the lazy-able part is the phone stack (dev carried it in the index too).

Result: index 238.33 -> 231.76 KB brotli (-6.57), first css 21.4 -> 18.98, new lazy chunk PhoneStack 8.57.

Gates, all green on aa107415c:

  • perf/web.sh --bundle-only --gate (dev-01): exit 0
  • bun run check: 0 errors (19 pre-existing warnings); bun run test (vitest): 34 files, 319 tests passed
  • Playwright style-sheet app-switch sidebar-arrange notes-sidebar-tree tables keys-no-motion switching lazy-ui notes-float-phone phone-foot phone-bars, server binary built from 6a3ef2e83: chromium-1440 84 passed, chromium-390 295 passed (dev-01); webkit-1440 84 passed, webkit-390 295 passed (dev-02); skipped = specs for the other viewport.

Real Safari on macos-01 (Mac lock, Safari + safaridriver quit by the EXIT trap), base 6a3ef2e83 vs trim, ABAB, loopback, medians of FCP / driver-seen ready:

  • wide 1440: FCP 62-66 vs 65-74 ms; ready 187-231 vs 217-225 ms (inside the run-to-run spread; mean FCP 72-103 vs 68-79)
  • narrow 520 (phone layout): FCP 60-68 vs 62-66 ms; ready ~200-226 vs ~203-218 ms. The PhoneStack chunk arrives at 26-35 ms, before the first paint, so the phone's first frame does not wait on it.
  • wide window narrowed to a phone's width 2.5 s after load: stack drawn in 67-77 ms (base) vs 63-80 ms (trim). Before the idle prefetch was added it was 92 vs 176 ms; that is why wide screens fetch the chunk at idle.
  • Flake, same on both builds: now and then a load never mounts (#app empty, rAF running, no error): trim 3/48 and 1/16+, base 2/48 once the servers' ports were swapped (the failures follow neither the build nor the port). It looks like the known Safari IndexedDB hang before hydrate(); not caused by this change, noted for kayg.
## Evidence (head aa107415c; dev-01 x86 + dev-02 aarch64, same toolchain; PR #1142) **What Notes Float added to the index chunk** (per-module generated bytes from the sourcemap, `6a3ef2e83` vs dev `6c50dd99c`, raw; 46.5 KB raw = ~13 KB brotli): behind-glass 9.1 K, LibraryTab 6.2 K, Selector 3.6 K, AppSwitch 3.6 K, WindowLayout 3.6 K, behind.ts 2.0 K, app-swipe 2.0 K, TreeRow 1.8 K, NotesSide 1.7 K, arrange-drag 1.4 K, page-style 1.3 K, Shell +1.2 K, glass-rules 1.2 K, GlobalLayer 1.1 K, idle-rows 1.1 K, Tabs +1.1 K, tag-tree 1.0 K, tree-arrange 0.9 K, custom-backdrop 0.9 K, SideTabs 0.7 K, WindowDock 0.6 K, the rest under 0.6 K each. Almost all of it is the first frame of the window; the lazy-able part is the phone stack (dev carried it in the index too). **Result:** index 238.33 -> 231.76 KB brotli (-6.57), first css 21.4 -> 18.98, new lazy chunk `PhoneStack` 8.57. **Gates, all green on aa107415c:** - `perf/web.sh --bundle-only --gate` (dev-01): exit 0 - `bun run check`: 0 errors (19 pre-existing warnings); `bun run test` (vitest): 34 files, 319 tests passed - Playwright `style-sheet app-switch sidebar-arrange notes-sidebar-tree tables keys-no-motion switching lazy-ui notes-float-phone phone-foot phone-bars`, server binary built from 6a3ef2e83: chromium-1440 84 passed, chromium-390 295 passed (dev-01); webkit-1440 84 passed, webkit-390 295 passed (dev-02); skipped = specs for the other viewport. **Real Safari on macos-01 (Mac lock, Safari + safaridriver quit by the EXIT trap), base 6a3ef2e83 vs trim, ABAB, loopback, medians of FCP / driver-seen ready:** - wide 1440: FCP 62-66 vs 65-74 ms; ready 187-231 vs 217-225 ms (inside the run-to-run spread; mean FCP 72-103 vs 68-79) - narrow 520 (phone layout): FCP 60-68 vs 62-66 ms; ready ~200-226 vs ~203-218 ms. The PhoneStack chunk arrives at 26-35 ms, before the first paint, so the phone's first frame does not wait on it. - wide window narrowed to a phone's width 2.5 s after load: stack drawn in 67-77 ms (base) vs 63-80 ms (trim). Before the idle prefetch was added it was 92 vs 176 ms; that is why wide screens fetch the chunk at idle. - Flake, same on both builds: now and then a load never mounts (`#app` empty, rAF running, no error): trim 3/48 and 1/16+, base 2/48 once the servers' ports were swapped (the failures follow neither the build nor the port). It looks like the known Safari IndexedDB hang before `hydrate()`; not caused by this change, noted for kayg.
Author
Owner

Runtime perf (perf-01, PERF_TURN_FRONT=1 ~/bin/perf-turn, perf-02 lock taken inside, own fixture copy, own staged dists sha256-checked, typing + list CPU harness typing-list-cpu.mjs)

Arms: dev and dev2 = base 6a3ef2e83 (dev2 = control), new = this head, nw = this change without the idle prefetch. Ratios to dev, mean with the 95% upper bound; 8 samples per arm, rotating order, one session each.

Session 2 (4 arms, the valid one for the final head):

metric new nw dev2 (control)
typing cpu ms/key +0.02% (+0.26) -0.21% (-0.03) +0.09% (+0.50)
typing script ms/key -1.56% (-0.49) -1.57% (-0.59) -0.21% (+1.48)
list cpu ms +0.18% (+0.83) +0.89% (+1.59) +0.71% (+1.57)
list script ms +0.28% (+3.66) +2.13% (+4.49) +0.24% (+2.42)
list layout ms +0.01% (+3.14) -1.52% (+1.54) +1.73% (+4.16)
list recalc ms +0.01% (+4.22) -0.61% (+1.36) +0.57% (+3.47)

Session 1 (3 arms, same dist as new): typing cpu +0.72% (+1.47) vs control +0.06%; list cpu +1.40% (+2.41) vs control +0.25%; list script +1.97% (+5.61) vs control -2.42%. That session read slightly worse than its control and I cannot explain it; session 2, run an hour later with a longer rotation, has new at or below its control everywhere. Reported both; I would call runtime flat (the code that runs per key and per list switch is unchanged; the only runtime difference is one idle fetch of an 8.6 KB chunk on wide screens), but the orchestrator may want its own comparator turn before release. A first session (invalid) was thrown away: my perf-02 lock watcher died after 3 minutes (background limit), so I stopped it and re-ran with the watcher as a systemd unit.

Cleanup done: perf-01 ~/nft-perf removed, both locks released, Mac lock released and Safari/safaridriver quit, dev-01/dev-02 worktrees and /tmp dists removed.

## Runtime perf (perf-01, `PERF_TURN_FRONT=1 ~/bin/perf-turn`, perf-02 lock taken inside, own fixture copy, own staged dists sha256-checked, typing + list CPU harness `typing-list-cpu.mjs`) Arms: `dev` and `dev2` = base 6a3ef2e83 (dev2 = control), `new` = this head, `nw` = this change without the idle prefetch. Ratios to `dev`, mean with the 95% upper bound; 8 samples per arm, rotating order, one session each. Session 2 (4 arms, the valid one for the final head): | metric | new | nw | dev2 (control) | |---|---|---|---| | typing cpu ms/key | +0.02% (+0.26) | -0.21% (-0.03) | +0.09% (+0.50) | | typing script ms/key | -1.56% (-0.49) | -1.57% (-0.59) | -0.21% (+1.48) | | list cpu ms | +0.18% (+0.83) | +0.89% (+1.59) | +0.71% (+1.57) | | list script ms | +0.28% (+3.66) | +2.13% (+4.49) | +0.24% (+2.42) | | list layout ms | +0.01% (+3.14) | -1.52% (+1.54) | +1.73% (+4.16) | | list recalc ms | +0.01% (+4.22) | -0.61% (+1.36) | +0.57% (+3.47) | Session 1 (3 arms, same dist as `new`): typing cpu +0.72% (+1.47) vs control +0.06%; list cpu +1.40% (+2.41) vs control +0.25%; list script +1.97% (+5.61) vs control -2.42%. That session read slightly worse than its control and I cannot explain it; session 2, run an hour later with a longer rotation, has `new` at or below its control everywhere. Reported both; I would call runtime flat (the code that runs per key and per list switch is unchanged; the only runtime difference is one idle fetch of an 8.6 KB chunk on wide screens), but the orchestrator may want its own comparator turn before release. A first session (invalid) was thrown away: my perf-02 lock watcher died after 3 minutes (background limit), so I stopped it and re-ran with the watcher as a systemd unit. Cleanup done: perf-01 `~/nft-perf` removed, both locks released, Mac lock released and Safari/safaridriver quit, dev-01/dev-02 worktrees and /tmp dists removed.
Author
Owner

Merged into port/notes-float with --no-ff at 62125f0b4 by the orchestrator. The final release perf gate re-measures typing/list on a clean fixture (session-1 ambiguity) and adds phone-width first paint in the iPhone Simulator (the phone now fetches PhoneStack before its first frame). Closing.

Merged into `port/notes-float` with `--no-ff` at `62125f0b4` by the orchestrator. The final release perf gate re-measures typing/list on a clean fixture (session-1 ambiguity) and adds phone-width first paint in the iPhone Simulator (the phone now fetches PhoneStack before its first frame). Closing.
kayg closed this pull request 2026-11-14 23:12:53 +00:00
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!1142
No description provided.