GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — perf(web): a thread loaded from the cache holds each item once by Pyseph · Pull Request #31483 · pingdotgg/t3code Conversation
|
| the card is | record | result |
|---|---|---|
| inside the visible window | compact, card left out of turnItems |
answerable, no refetch |
| older than the window | compact, card kept after the visible rows | answerable, no refetch |
| older than the window, with newer items after it | not compacted, both copies | answerable, no refetch, items shared |
| missing | compact | discarded and fetched again, as #26435 does |
A focused memory fix with no intended visible change, following a maintainer's own mobile change. I think it fits as a small fix; a triaged issue is fine if you prefer one.
Tests on this branch, on main at 337c5858c3 (gist, tests-cache-only.log):
packages/client-runtime/src/platform/threadCacheEncoding.test.ts (new, 5 tests): an item written once, one object per item after decoding, a record that could not be compacted, a version 5 record shared when equal and kept when different. Against main's threadCacheEncoding.ts, the tests for the uncompacted record and the version 5 record fail, with the third pending-question case below (gist, tests-against-main.log). The rest pass there, because version 6 already shared items.apps/web/src/connection/storage.test.ts: "saves each item once and loads it as one object". It fails against main's storage.ts, with the output written twice.threads-sync.test.ts, the "a pending question in a saved record" block above (4 tests). Without the sharing for uncompacted records, the third case and the new encoding test fail.orchestrationCache.test.ts, threadDetail.test.ts, threads-atoms.test.ts, the rest of threads-sync.test.ts, threadHistoryMerge.test.ts (client-runtime 92 tests in all), apps/mobile/src/connection/environment-cache-store.test.ts (8), ProjectionStore.test.ts and threadHistoryPaging.test.ts (79, the server tests fix: keep older pending questions answerable #26435 touched), web ChatView.logic.test.ts and its timeline neighbours (160 with storage.test.ts), ChatView.browser.test.tsx (1).effect-tsgo tsrs --noEmit for packages/client-runtime and apps/web: 0 errors. vp fmt --check and vp lint on the changed files pass, and so did the pre-commit hook (fmt, lint, knip) under Node 26. Web tests ran on Windows with system Chrome and a local vite.config.ts workaround for a path with spaces, which is not part of this change.Measurements: the whole AppRoot on the in-process fake environment with synthetic threads already in IndexedDB, opened as after a restart, headless Chrome, two forced GCs per reading, Vite dev build. The fake answers a resume with no new snapshot, as a real server does when nothing changed.
Harness: the harness-- files in gist. apply.mjs puts the measurement-only switches and renderer.ram.tsx on a checkout (BRANCH1=1 for this branch), one.sh runs one scenario, matrix.ps1 alternates the arms, agg.mjs builds the tables. They carry placeholders for my paths and expect the folder layout they ran in, so they need small changes to rerun.
Re-check on this branch, on current main, n=3 alternating, R30 at 12 threads (gist, recheck-cache.ndjson):
| main | this branch | |
|---|---|---|
| JS heap after opening all 12, MB, median (min) | 948.4 (948.4) | 594.9 (591.0) |
| saved cache, MB | 717.4 | 361.2 |
"main" is this branch with the old record format and no sharing on decode, switched by a measurement-only switch. This branch has neither #31464 nor the closure fix, and the saving is the same as in the table below.
The fuller table below was measured before the rebase, 5 alternating runs per arm, on a base that already had #31464. The "this change" arm also had the two-closure fix from #31484. While every thread in the table is still warm, that fix frees nothing, because the copy it lets go of is still retained.
| threads opened, size of each | JS heap, before | JS heap, this change | saved cache |
|---|---|---|---|
| 20, W10 (10 turns, about a first-open server window) | 248.2 (244.5) | 246.8 (241.7) | 3.1 -> 2.0 MB |
| 20, W100 (100 turns as the wire sends them) | 276.8 (276.3) | 260.6 (260.4) | 31.5 -> 19.7 MB |
| 12, W500 (500 turns as the wire sends them) | 336.6 (336.0) | 288.5 (283.1) | 95.1 -> 59.3 MB |
| 12, R30 (30 MB of large bodies each) | 949.7 (948.2) | 594.1 (594.0) | 717.4 -> 361.2 MB |
MB, median (min), n=5 (gist, heap-seeded.ndjson, tables-heap.txt). The shell-only phase varies between about 192 and 200 MB across runs, so the W10 row is within noise.
First paint does not change: opening from the cache takes 582.5 -> 589.0 ms at W100 and 863.7 -> 841.9 ms at R30 (medians, n=30 and n=20, exclusive timing lock, before the rebase; gist, cold.ndjson). I expected decoding half the data to show here, and it does not.
A record above 133 MB cannot be saved at all: IndexedDB fails it with "The serialized keys and/or value are too large (size=215123491 bytes, max=133169152 bytes)" (gist, heap-seeded.ndjson). The compact record doubles how large a thread fits.
The real server and wire path, a production build, Safari or Firefox storage, and mobile on a device. The R30 sizes stand in for large text, because the real wire omits command output and diffs (projectTurnItemForWire). How often real threads fall back to an uncompacted record: the sharing covers them either way, but they get no saving on disk.
Claude Opus 5.5 in T3 Code (Claude Code harness).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Web and desktop now write the compact record mobile already uses, so a saved thread takes about half the space. Decoding also shares equal item copies and message bodies again, including in records saved before this change and in records that could not be compacted, so a thread from the cache costs what a thread from the server costs. A pending question's card survives the round trip whether it sits inside the visible window, older than it, or older with newer items after it, and a record with no card is still fetched again.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This reduces cached-thread memory duplication by using the shared compact codec and sharing equivalent decoded items and bodies. The effects are confined to local caches, with compatibility checks and invalid-cache discard retained. You can add or adjust custom eligibility rules. Learn more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Note Written by Merged current
Effect of the cap on the numbers in the description: a record over 4 MB is no longer cached on Checked: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…out decode sharing The storage and thread-sync cases repeated the compact round-trip one layer up; mobile already exercised that path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The automated pipeline stopped on this pull request and will not merge it: the capture step could not show the problem on the base commit, so there is nothing to prove fixed. Seeded eight threads per commit through thread start/send using devReplay command-output, twenty turns each, with deterministic unique 50,000-character user bodies. Opened all eight threads and Settings to populate each browser's cache. Alternated base and head for five browser restarts, opening all eight cached threads through sidebar buttons. Measured click-event to the final assistant paragraph appearing inside the viewport, then requested two garbage collections, recorded Runtime.getHeapUsage, and counted heap-snapshot body strings with self_size >= 40,000 bytes. Repeated five fresh-profile server-control runs per commit. Compared message-content hashes, item counts, and local/visible object identity. Recorded an additional identical navigation pass per commit, excluded from statistics; stills required two byte-identical screenshots 500 ms apart. It stays open for a person to finish or close. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ms-once Co-Authored-By: Claude Opus 5.5 <[email protected]>
4a6cc83 to
d21428b
Compare
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.