Skip to content

perf(client): reduce thread-list update work - #9716

Merged
t3dotgg merged 1 commit into
mainfrom
t3code/perf-thread-shell-list-atoms
Sep 4, 2026
Merged

perf(client): reduce thread-list update work#9716
t3dotgg merged 1 commit into
mainfrom
t3code/perf-thread-shell-list-atoms

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Sep 4, 2026

Copy link
Copy Markdown
Member

The shared thread list keeps one atom active for every listed thread. One shell update makes the registry revisit those dependencies across the whole environment.

Build aggregate lists from the environment data and share weakly cached values with point reads. Reuse project membership maps when their entries and order stay the same. Keep thread identity, list order, project moves, and multi-environment behavior unchanged.

In a 10,000-thread fixture, the list and project-reference groups retain 5 registry nodes instead of 10,008. Median update time fell from 41.2 ms to 3.4 ms. This measures the real reducer and shared atoms, not React rendering or device performance.

All 21 focused tests, client-runtime typecheck, and targeted lint pass. An independent source review found no blocker. No wire changes, browser, device, or live state use.

Part of #9661.

Created with GPT-6 Astra (preview) in Codex.


Note

Medium Risk
Changes core client reactivity graph for thread lists; behavior is heavily tested but incorrect identity or ordering would affect all thread UI consumers.

Overview
Thread list updates no longer fan out through one atom per thread. Aggregate threadShellsAtom and threadShellsForProjectRefsAtom now walk environment snapshot threads and build scoped shells directly, instead of subscribing to each threadShellAtom in the list.

Scoped shell objects are shared between list reads and point reads via a WeakMap cache keyed by source OrchestrationThreadShell, so list composition does not keep per-thread shell atoms alive. Per-thread threadShellAtom uses the same cache. environmentThreadRefsByProjectAtom also reuses the previous map when project keys, order, and ref arrays are unchanged.

Tests extend the harness for multiple environments and add coverage for registry node count (~200 threads stays under 20 nodes), reference identity after partial updates, and multi-environment ordering, project moves, removals, and catalog changes.

Reviewed by Cursor Bugbot for commit 999fa14. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Reduce thread-list update work in createEnvironmentThreadShellAtoms

  • Adds a WeakMap-based cache that scopes each source thread shell per environment and reuses the value across point reads and aggregate lists, eliminating one point atom per listed thread
  • Project-reference grouping now reuses the previous outer map when project order and per-project reference arrays are unchanged, preserving object identity across unrelated updates
  • Global thread list and project lists now read environment indexes and catalog order directly through the shared cache instead of traversing the thread-reference list and point-atom family
  • Adds multi-environment test coverage for identity sharing, list ordering, deduplication, catalog filtering, and environment emptying in entities.test.ts
  • Risk: aggregate read ordering and membership now follow current project references, catalog entries, and environment snapshot threads directly — callers relying on stale point-atom values may see different results

Macroscope summarized 999fa14.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.8 KiB 13.5 KiB −236 B (−1.7%) 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.0 KiB −2 B (−0.0%) 7.3 KiB
Codex Live turn WebSocket wire 6.7 KiB 6.5 KiB −234 B (−3.4%) 7.8 KiB
Codex Live turn WebSocket decoded 58.5 KiB 57.0 KiB −1.5 KiB (−2.6%) 66.4 KiB
Codex Live turn messages 10 8 −2 (−20.0%) 21
Claude Total thread wire 13.7 KiB 13.5 KiB −199 B (−1.4%) 15.1 KiB
Claude Thread snapshot wire 7.0 KiB 7.0 KiB +2 B (+0.0%) 7.3 KiB
Claude Live turn WebSocket wire 6.7 KiB 6.5 KiB −201 B (−2.9%) 7.8 KiB
Claude Live turn WebSocket decoded 59.3 KiB 57.8 KiB −1.5 KiB (−2.5%) 66.4 KiB
Claude Live turn messages 10 9 −1 (−10.0%) 21

Baseline: da7e46d · PR result: 999fa14 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.8 KiB
  • Claude decoded thread snapshot: 114.5 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 999fa14

Macroscope's review found this PR approvable — This is a contained client-runtime performance refactor that reduces per-thread atom work while preserving thread data, scoping, ordering, and update behavior. Targeted tests cover identity reuse, large lists, environment/project changes, and lifecycle updates.

You can add or adjust custom eligibility rules. Learn more.

@t3dotgg
t3dotgg merged commit c66f15f into main Sep 4, 2026
24 checks passed
@t3dotgg
t3dotgg deleted the t3code/perf-thread-shell-list-atoms branch September 4, 2026 16:42
@t3dotgg t3dotgg mentioned this pull request Sep 4, 2026
66 tasks
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Sep 4, 2026
## What's Changed
* perf(server): use one query for buffered provider events by @t3dotgg in pingdotgg/t3code#9706
* perf(relay): avoid repeated activity decoding by @t3dotgg in pingdotgg/t3code#9708
* perf(web): stop continuous chat status animations by @t3dotgg in pingdotgg/t3code#9709
* fix(mobile): preserve saved work after storage read failures by @t3dotgg in pingdotgg/t3code#9710
* perf(web): stop replaying terminal buffers on rollover by @t3dotgg in pingdotgg/t3code#9707
* feat(web): preview pull request links by @maria-rcks in pingdotgg/t3code#9631
* perf(client): reduce thread-list update work by @t3dotgg in pingdotgg/t3code#9716
* fix(server): settle inactive threads with open PRs by @Gigioxx in pingdotgg/t3code#9610
* fix(server): bound slow-client event buffers by @t3dotgg in pingdotgg/t3code#9715
* test(server): allow either valid file-search match by @t3dotgg in pingdotgg/t3code#9720
* fix(web): match provider settings layout for disconnected devices by @flamboh in pingdotgg/t3code#9619
* fix(web): keep the slash menu above the composer when vertical space is short by @Mnigos in pingdotgg/t3code#9625
* fix(mobile): remove provider setup by @juliusmarminge in pingdotgg/t3code#9721
* perf(web): stop rendering hidden terminals by @t3dotgg in pingdotgg/t3code#9718
* fix(mobile): read file-backed image drafts before enabling them by @t3dotgg in pingdotgg/t3code#9713
* perf(server): replay only the selected thread by @t3dotgg in pingdotgg/t3code#9726
* fix(web): mute composer helper text by @jakeleventhal in pingdotgg/t3code#9654
* feat(web): unpin threads from the sidebar multi-select menu by @gsimone in pingdotgg/t3code#9651
* perf(web): reuse timeline rows while text streams by @t3dotgg in pingdotgg/t3code#9725
* fix(relay): bound stalled push requests by @t3dotgg in pingdotgg/t3code#9734
* perf(server): stop caching unused OpenCode tool parts by @t3dotgg in pingdotgg/t3code#9738
* fix(web): fold single trailing activity by @maria-rcks in pingdotgg/t3code#9739
* fix(web): show project settings for new threads by @maria-rcks in pingdotgg/t3code#9743
* perf(mobile): bound the parsed review cache by @t3dotgg in pingdotgg/t3code#9749


**Full Changelog**: pingdotgg/t3code@v0.0.39-nightly.20260904.1279...v0.0.39-nightly.20260904.1280

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.39-nightly.20260904.1280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant