Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Thread opens take seconds with ~5,000 unarchived threads; client work scales with every settled thread in the shell #22372

ClosedWhiteWarrior625(GitHub profile, opens in a new tab) opened this issue 4 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Related, each narrower: #18926 (shell cache encode cost, fixed), #3962 (collapse animation), #21371 (database growth). PR #13657 (auto-archive settled threads) was closed without merging, so nothing archives threads unless a user does it by hand.

Area

apps/web

Steps to reproduce

  1. Run agents that create threads through MCP (delegated tasks, t3_thread_launch) for a couple of weeks. On this install that came to about 270 new threads a day, and 4,906 unarchived threads after 18 days. Almost all of them were settled.
  2. Open any thread from the desktop sidebar while about 20 runs are active.
  3. Compare the client spans that the desktop app exports into server.trace.ndjson with the server's http.orchestration.loadThreadSnapshotWindow.

Expected behavior

A thread open costs about the same whether the install has 200 unarchived threads or 5,000. Settled threads hidden in the collapsed settled shelf cost nothing on each live update.

Actual behavior

The server answers quickly. The client spends seconds before and after that answer.

Over 20 minutes of normal use with 4,906 unarchived threads, the client spans were:

Spannp50p95max
http.orchestration.loadThreadSnapshotWindow (server)6614 ms124 ms376 ms
EnvironmentThreadState.make880 ms208 ms3,142 ms
web.connectionStorage.readDatabaseValue5341 ms439 ms3,012 ms
EnvironmentCommands.visitThread63266 ms3,792 ms10,763 ms
storage.saveShell222176 ms559 ms1,504 ms
storage.saveThread113102 ms1,013 ms3,319 ms

In the worst open, EnvironmentThreadState.make waited 3,012 ms on the IndexedDB read of the cached thread (threads.ts loads the cache before it subscribes). Two saveThread writes of 3.3 s and 1.3 s were in flight at the same time. In the slowest visitThread, the client waited 10.8 s, but no server-side dispatchCommand near that minute took longer than 1.5 s.

The renderer main thread was 24% busy with no user input, sampled from /proc/<pid>/task/<pid>/stat every 0.5 s for 60 s, with bursts to 96%. Its working set was about 1.1 GB, peaking at 2.6 GB.

I then archived the 3,281 settled threads that agents had created, leaving 1,639 unarchived threads, and changed nothing else:

Spanmax beforemax after
web.connectionStorage.readDatabaseValue3,012 ms48 ms
EnvironmentThreadState.make3,142 ms76 ms
EnvironmentCommands.visitThread10,763 ms221 ms
storage.saveShell1,504 ms244 ms

The main thread at rest dropped to 12%. The after-sample is small: 14 thread opens over about 4 minutes.

From reading the source at d36b7da2485b, these costs grow with the number of active-shell threads on every shell update, not only on open:

  • shellReducer.ts:160-182: find plus upsertById (findIndex and map) produce a new N-element array for each thread.updated.
  • Sidebar.tsx:457 subscribes to all thread shells. Each render runs partitionSidebarThreads (:601-692), which filters, builds keys, and sorts with Date.parse and localeCompare across all N threads, even when the settled shelf is collapsed to 10 rows.
  • The derived atoms in threadShell.ts (:64, :170, :195, :210, :376) and useThreadVisitedMigration.ts:19-39 each iterate all threads.
  • saveShell still writes the whole shell to IndexedDB about every 10.5 s, through cachePersistence.ts. The thread cache read on open shares that IndexedDB.

Settled threads stay in the active shell until someone archives them by hand (ws.ts:987 loads location: "active"). So on an install where agents create threads, this cost grows without limit.

Impact

Major degradation or frequent failure

Version or commit

0.1.1-nightly.20261020.3411 (d36b7da2485b), official Linux AppImage

Environment

Ubuntu, kernel 7.0, desktop app (Electron) with a local server. 16-core machine, NVMe storage. statev2.sqlite is 38 GB.

Workaround

Archive settled threads in bulk through thread.archive commands. A daily job now archives anything settled for 7 days.

Suggested direction

Either of these would remove the growth:

  • Keep settled threads out of the per-update work: a separate, lazily loaded settled list, with no full re-sort for the collapsed shelf.
  • An opt-in archive-after-N-days-settled setting, the scope of #13657. That is a feature, so I can open an Ideas discussion if you prefer it go there.
  1. Tested current main 5c3721e20a in Chromium through vp run dev --no-seed, with isolated worktree state: 5,000 synthetic threads (4,980 settled, shelf collapsed), plus the app's scratch thread. Ten scripted opens took 331–645 ms (median 429 ms). Archiving 4,800 of the same threads gave 306–639 ms (median 400 ms). These are development-build measurements with a temporary React commit profiler, measured from sidebar click through the updated thread view and two animation frames.

    The server's thread snapshot window took a median 7.8 ms, max 24 ms in the 5,000-thread runs. One captured open fetched 1,120 bytes over HTTP; the socket sent a 1,516-byte single-thread shell update and a synchronization marker, not the full list. Sidebar partitioning scanned all 5,001 rows in about 5–9 ms per call. The largest captured IndexedDB read was 207 ms; shell saves peaked at 528 ms. A separate 160-command metadata-update burst across 20 threads kept ten measured opens at 363–635 ms. That burst is a shell-update surrogate, not 20 running providers.

    I have not reproduced the multi-second cache reads or thread opens. This seed has empty histories and no PR links, and does not reproduce the Linux Electron renderer or the original provider workload. Could you attach a sanitized trace covering one slow open on a current nightly, with its timestamp and concurrent run count? Shell-cache size and the approximate number of PR links would help distinguish render work from IndexedDB contention. No full database or credentials needed.

    Recordings with on-screen timestamps: 5,000 threads, metadata-update load, 200 unarchived threads.

  2. juliusmarminge added labelsneeds more info

  3. Thanks for testing. Here is a trace from this install, 2026-10-22 15:35–16:15 UTC, during normal use.

    Build: 0.1.2-nightly.20261021.3486 (680152e27b2a), official Linux AppImage, desktop app with a local server. Three newer nightlies exist (latest 20261022.3526, f054d1b80187). I didn't upgrade with runs in progress. The code path below is identical in f054d1b80187 and on main.

    Load at the time: about 39 open runs (queued or running) across 22 threads; at 15:52, 20 running, 21 queued, 1 starting. 2,060 unarchived threads (630 settled), down from 4,906 after the archive job; 5,873 threads in total. statev2.sqlite is 43 GB. Shell cache: renderer IndexedDB is 38 MB of LevelDB plus a 1.4 GB blob store (3,709 blobs). Server-side, the unarchived thread payloads total 4.4 MB. PR links: 1,471 links on 793 unarchived threads (1,890 in total). The thread I named before, f46885a7, has 12.

    What it shows

    Archiving fixed the client side I reported: readDatabaseValue p50 is 46 ms (max 1,066 ms), and EnvironmentThreadState.make p50 is 10 ms. Opens are still slow. From EnvironmentThreadState.make to the first applyItems from subscribeThread: n=73, p50 1.7 s, p95 9.5 s, max 21.0 s. Of the 18 opens that took 4 s or more:

    • 7 waited on the SQLite writer inside ensureLegacyTranscript, for 0.9–20.8 s. subscribeThread runs ensureLegacyTranscript first. LegacyV1ThreadImporter.ts:684-700 adds a thread to confirmedTranscriptThreadIds only when it has an orchestration_v2_legacy_imports row. On this install that table has 0 rows, so no thread ever takes the fast path. Every open, and every command that calls ensureCommandTranscripts, takes the per-thread lock and runs the lookup, and the spans show that lookup on db.connection: writer. With about 20 runs writing events, it waits for the writer. The slowest open (16:07:56, thread 49fc2384) spent 20,820 ms of its 21,003 ms in that one SELECT's lock wait; the writer was held by publishThreadUnsafe for 38.4 s from 16:07:38. Caching the "no row" answer too, or running the lookup on a reader, would take opens off the writer.
    • 8 had a 4.4–9.8 s gap between the client sending orchestration.subscribeThread and the server's ws.rpc.orchestration.subscribeThread starting. The server work then took milliseconds. The trace doesn't show where the request waited. No server event-loop stall was logged in that window.
    • 3 are unexplained: 15:38:51, 15:55:29 and 16:08:38. For the last two, data arrived 3.8–10.4 s after a fast server sync.

    Separately, at 15:41:49 a single orchestrationV2.EventSink.write (1 event, thread mcp:438c3b30…) held the writer transaction for 130.5 s. It had no child spans, and no event-loop stall was logged. 55 writer queries waited behind it, including a thread.visit for f46885a7 (127.7 s lock wait, then 1 ms of work), scheduled-task dispatch and ensureLegacyTranscript (77.9 s). Any open in that window would have waited the same way. I can't see from the trace what that transaction was doing.

    One more observation: most opens produce 3–6 server subscribeThread calls for the same thread within about 250 ms.

    All 73 opens

    Threads with ids that embed task names are shown as "(delegated-task thread)". A server subscribe is matched to the first one that starts within 12 s of the client's request, so rows for back-to-back opens can pick up a neighbour's subscribe.

    open (UTC)threadIndexedDB readclient sends subscribe → server handler startsserver initial syncof which ensureLegacyTranscriptits writer lock waitopen → first data applied
    15:35:57.199mcp:93209a2b-8945-484e-983e-f3a8568868ef42 ms1,261 ms6 ms0 ms0 ms1,574 ms
    15:37:17.5727f3a0adc-2f56-4ffa-8919-ae72c3ab395266 ms219 ms54 ms0 ms0 ms545 ms
    15:37:19.974mcp:6bbb1667-3295-4632-aee8-918506e5357012 ms31 ms54 ms0 ms0 ms382 ms
    15:38:32.637mcp:da2d7742-3648-4d7f-a627-aa29f61c46ff46 ms6 ms2 ms1 ms0 ms196 ms
    15:38:45.642(delegated-task thread)10 ms415 ms1,426 ms1,424 ms0 ms2,659 ms
    15:38:51.076(delegated-task thread)3 ms2,727 ms1 ms0 ms0 ms5,389 ms
    15:40:48.021mcp:6bbb1667-3295-4632-aee8-918506e53570930 ms11 ms0 ms0 ms2,887 ms
    15:44:22.6699a4f1ef5-3088-4e96-8c3b-6c0c27cd6be822 ms434 ms2,606 ms2,598 ms1,323 ms6,900 ms
    15:44:29.2997f3a0adc-2f56-4ffa-8919-ae72c3ab395267 ms147 ms1,459 ms1,384 ms1,227 ms2,038 ms
    15:44:31.007mcp:600d2dcb-c555-4c6b-bc16-7a520852b25571 ms1,081 ms1,078 ms269 ms1,219 ms
    15:44:46.794(delegated-task thread)6 ms52 ms35 ms34 ms34 ms590 ms
    15:44:47.637(delegated-task thread)5 ms119 ms1 ms0 ms0 ms247 ms
    15:45:38.006mcp:93209a2b-8945-484e-983e-f3a8568868ef1,301 ms4,869 ms4,865 ms4,865 ms8,472 ms
    15:45:38.006mcp:93209a2b-8945-484e-983e-f3a8568868ef1,300 ms4,869 ms4,865 ms4,865 ms4,518 ms
    15:46:12.5237f3a0adc-2f56-4ffa-8919-ae72c3ab39524,247 ms1,703 ms1,517 ms902 ms6,545 ms
    15:46:37.4767f3a0adc-2f56-4ffa-8919-ae72c3ab3952628 ms1,744 ms1,741 ms1,138 ms3,114 ms
    15:47:19.3657f3a0adc-2f56-4ffa-8919-ae72c3ab39521,220 ms1,955 ms1,952 ms1,247 ms3,785 ms
    15:47:47.262mcp:ee047d92-bfe0-4e4a-982e-2ad6d622a5ba142 ms1,349 ms6,498 ms6,495 ms3,360 ms9,455 ms
    15:48:09.063mcp:2094f738-8855-4fde-8b20-a5ceb4dee05351 ms715 ms6 ms0 ms0 ms2,025 ms
    15:49:10.528mcp:600d2dcb-c555-4c6b-bc16-7a520852b2551,659 ms5 ms0 ms0 ms1,846 ms
    15:49:30.8077f3a0adc-2f56-4ffa-8919-ae72c3ab395220 ms82 ms3 ms0 ms0 ms2,489 ms
    15:49:31.6397f3a0adc-2f56-4ffa-8919-ae72c3ab3952401 ms3 ms0 ms0 ms569 ms
    15:49:33.220(delegated-task thread)23 ms481 ms2 ms0 ms0 ms680 ms
    15:52:04.89249fc2384-af68-4d04-b2ec-4b7a50bb8b4817 ms5,519 ms1 ms0 ms0 ms6,905 ms
    15:54:01.218mcp:600d2dcb-c555-4c6b-bc16-7a520852b2555 ms7 ms0 ms0 ms141 ms
    15:54:02.127(delegated-task thread)8 ms36 ms2 ms0 ms0 ms362 ms
    15:54:02.486(delegated-task thread)3 ms65 ms2 ms0 ms0 ms223 ms
    15:54:40.919mcp:57c7a8a5-b75d-4a3a-8c9c-624259f52936204 ms8 ms6 ms0 ms0 ms297 ms
    15:55:29.983mcp:600d2dcb-c555-4c6b-bc16-7a520852b25541 ms106 ms4 ms0 ms0 ms10,523 ms
    15:55:52.662mcp:6ef76b38-f76c-4acd-aeba-9bc480d1dd01103 ms4,889 ms20 ms1 ms0 ms5,214 ms
    15:56:07.367mcp:fa047391-785c-454e-9cdf-a3c257aa8e93148 ms4,443 ms21 ms0 ms0 ms4,885 ms
    15:56:31.61449fc2384-af68-4d04-b2ec-4b7a50bb8b48269 ms46 ms0 ms0 ms525 ms
    15:56:38.316mcp:12e85481-132e-4a40-b21c-03e3fd258249247 ms2,083 ms46 ms0 ms0 ms2,512 ms
    15:58:31.608(delegated-task thread)6 ms26 ms1 ms0 ms0 ms187 ms
    15:58:32.782(delegated-task thread)1 ms351 ms1 ms0 ms0 ms969 ms
    15:59:30.443mcp:a580e409-9a0d-44be-8de0-f287c34875ed1,066 ms2 ms18 ms0 ms0 ms1,679 ms
    15:59:40.903mcp:bfdca20d-9b14-443a-9c88-d9c9031e2908175 ms3 ms8 ms0 ms0 ms457 ms
    15:59:47.563mcp:17acd3f5-cb05-4d06-870e-df3f294bb691128 ms37 ms8 ms0 ms0 ms589 ms
    15:59:55.6551aa7b3eb-705e-4931-b6fd-38e7a6a9a7152,211 ms6 ms0 ms0 ms2,860 ms
    16:00:01.0251aa7b3eb-705e-4931-b6fd-38e7a6a9a7153,920 ms2 ms0 ms0 ms3,990 ms
    16:00:14.682mcp:ed3f394b-b11d-4e90-909c-f467d60ce2e952 ms387 ms10 ms1 ms0 ms567 ms
    16:00:20.420mcp:8205f851-f7da-4a03-b8f1-3dc903ca97f967 ms19 ms4 ms0 ms0 ms289 ms
    16:00:32.531mcp:bf6220ee-eab2-4c24-84d1-913c944d7572168 ms212 ms10 ms1 ms0 ms486 ms
    16:00:42.051(delegated-task thread)41 ms34 ms4 ms0 ms0 ms156 ms
    16:00:43.147(delegated-task thread)1 ms125 ms4 ms0 ms0 ms416 ms
    16:00:52.784mcp:6bbb1667-3295-4632-aee8-918506e53570144 ms130 ms4 ms0 ms0 ms358 ms
    16:00:54.084mcp:bf6220ee-eab2-4c24-84d1-913c944d757213 ms4 ms0 ms0 ms81 ms
    16:00:59.679mcp:6bbb1667-3295-4632-aee8-918506e5357017 ms4 ms0 ms0 ms166 ms
    16:01:05.038mcp:93209a2b-8945-484e-983e-f3a8568868ef228 ms104 ms4 ms0 ms0 ms624 ms
    16:01:32.753mcp:438c3b30-5206-4f9f-be07-e45ee3b319b976 ms6,855 ms8 ms0 ms0 ms7,369 ms
    16:01:52.813mcp:ee047d92-bfe0-4e4a-982e-2ad6d622a5ba169 ms6,785 ms5 ms0 ms0 ms7,677 ms
    16:02:09.1619a4f1ef5-3088-4e96-8c3b-6c0c27cd6be846 ms5,245 ms97 ms0 ms0 ms5,833 ms
    16:03:18.47549fc2384-af68-4d04-b2ec-4b7a50bb8b4873 ms1,930 ms5 ms1 ms0 ms2,483 ms
    16:03:24.127(delegated-task thread)2 ms2,869 ms3 ms1 ms0 ms3,808 ms
    16:04:24.356mcp:411327df-0143-4a81-94ee-a9669a6e475072 ms5,019 ms12 ms0 ms0 ms5,332 ms
    16:04:40.453mcp:12e85481-132e-4a40-b21c-03e3fd258249215 ms1 ms0 ms0 ms235 ms
    16:05:04.213mcp:93209a2b-8945-484e-983e-f3a8568868ef62 ms2 ms0 ms0 ms227 ms
    16:06:05.458(delegated-task thread)21 ms2,862 ms1,840 ms1,835 ms1,835 ms5,792 ms
    16:06:13.358(delegated-task thread)1 ms1,437 ms11 ms1 ms0 ms3,710 ms
    16:06:28.5217f3a0adc-2f56-4ffa-8919-ae72c3ab3952360 ms96 ms46 ms0 ms0 ms1,386 ms
    16:07:23.0327f3a0adc-2f56-4ffa-8919-ae72c3ab3952336 ms157 ms151 ms126 ms1,065 ms
    16:07:56.09349fc2384-af68-4d04-b2ec-4b7a50bb8b482 ms20,821 ms20,820 ms20,820 ms21,003 ms
    16:08:38.30149fc2384-af68-4d04-b2ec-4b7a50bb8b481,306 ms8 ms0 ms0 ms5,150 ms
    16:09:08.5577f3a0adc-2f56-4ffa-8919-ae72c3ab3952657 ms1,752 ms1,750 ms1,329 ms2,709 ms
    16:09:11.728(delegated-task thread)8 ms1,091 ms2 ms0 ms0 ms1,936 ms
    16:09:14.369(delegated-task thread)1 ms1,452 ms1 ms0 ms0 ms3,234 ms
    16:10:01.5319a4f1ef5-3088-4e96-8c3b-6c0c27cd6be89,842 ms3 ms0 ms0 ms10,020 ms
    16:10:24.874mcp:6eed729f-d315-4f11-becb-fa72a9aedaeb17 ms60 ms5 ms0 ms0 ms130 ms
    16:10:38.88349fc2384-af68-4d04-b2ec-4b7a50bb8b48294 ms1 ms0 ms0 ms3,745 ms
    16:11:49.105mcp:93209a2b-8945-484e-983e-f3a8568868ef1,157 ms11 ms1 ms0 ms1,239 ms
    16:11:51.512mcp:a580e409-9a0d-44be-8de0-f287c34875ed72 ms109 ms11 ms1 ms0 ms747 ms
    16:12:55.233(delegated-task thread)53 ms74 ms2 ms0 ms0 ms305 ms
    16:15:22.916mcp:12e85481-132e-4a40-b21c-03e3fd25824958 ms855 ms19 ms0 ms0 ms1,231 ms

    Span stats over the window (ms):

    EnvironmentThreadState.make: n=83 p50=10 p95=327 max=2527 ms
    web.connectionStorage.readDatabaseValue: n=85 p50=46 p95=511 max=1066 ms
    storage.saveShell: n=218 p50=177 p95=688 max=1897 ms
    storage.saveThread: n=133 p50=112 p95=1818 max=25110 ms
    http.orchestration.loadThreadSnapshotWindow: n=204 p50=17 p95=298 max=6679 ms
    ws.orchestrationV2.subscribeThread: n=205 p50=4 p95=1955 max=20821 ms
    orchestrationV2.threadManagement.ensureLegacyTranscript: n=1282 p50=0 p95=237 max=77885 ms
    Sanitized spans: slowest open (16:07:56) and the 130 s writer hold (NDJSON)

    These come from server.trace.ndjson, which includes the client spans the desktop app exports. Attributes are limited to rpc.method, thread ids, command type, db.connection, db.lock_wait_ms and the first 70 characters of the SQL. Paths, environment ids and payloads are removed.

    {"name":"EnvironmentThreadState.make","traceId":"dff3993a09e1f8cf990136e235519ddf","spanId":"1f61b1d1f9db483b","parentSpanId":null,"startUtc":"16:07:56.093","durationMs":0.1,"exit":null,"attributes":{}}
    {"name":"EnvironmentRpc.subscribe","traceId":"dff3993a09e1f8cf990136e235519ddf","spanId":"776ca8b358bab31a","parentSpanId":"1f61b1d1f9db483b","startUtc":"16:07:56.094","durationMs":137666.6,"exit":null,"attributes":{"rpc.method":"orchestration.subscribeThread","effect.fiber.interrupted":true}}
    {"name":"runCachePersistence","traceId":"dff3993a09e1f8cf990136e235519ddf","spanId":"faa9574717d4aa42","parentSpanId":"1f61b1d1f9db483b","startUtc":"16:07:56.094","durationMs":137666.7,"exit":null,"attributes":{"effect.fiber.interrupted":true}}
    {"name":"environment.initialSync","traceId":"dff3993a09e1f8cf990136e235519ddf","spanId":"4eeece2a4e4ffc71","parentSpanId":"d25d97d64c4c296a","startUtc":"16:07:56.103","durationMs":0.1,"exit":null,"attributes":{}}
    {"name":"EnvironmentThreadState.makeSubscribeInput","traceId":"dff3993a09e1f8cf990136e235519ddf","spanId":"d25d97d64c4c296a","parentSpanId":"776ca8b358bab31a","startUtc":"16:07:56.103","durationMs":0.1,"exit":null,"attributes":{}}
    {"name":"orchestration.subscribeThread","traceId":"dff3993a09e1f8cf990136e235519ddf","spanId":"38a1cc12b31ee3e7","parentSpanId":"776ca8b358bab31a","startUtc":"16:07:56.103","durationMs":137657.5,"exit":null,"attributes":{"rpc.method":"orchestration.subscribeThread","effect.fiber.interrupted":true}}
    {"name":"EnvironmentThreadState.applyItems","traceId":"dff3993a09e1f8cf990136e235519ddf","spanId":"e2bde044d08a30f9","parentSpanId":"1f61b1d1f9db483b","startUtc":"16:08:17.096","durationMs":0.2,"exit":null,"attributes":{}}
    {"name":"ws.orchestrationV2.subscribeThread","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"5a8787d23760e14b","parentSpanId":"e615b0ffc0a218bb","startUtc":"16:07:56.105","durationMs":20821.3,"exit":"Success","attributes":{"orchestration_v2.thread_id":"49fc2384-af68-4d04-b2ec-4b7a50bb8b48"}}
    {"name":"orchestrationV2.threadManagement.ensureLegacyTranscript","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"d3d3a72296a2fba0","parentSpanId":"5a8787d23760e14b","startUtc":"16:07:56.105","durationMs":20820.4,"exit":"Success","attributes":{}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"531969658cd92ded","parentSpanId":"d3d3a72296a2fba0","startUtc":"16:07:56.105","durationMs":20820.3,"exit":"Success","attributes":{"db.query.text":"SELECT thread_id, transcript_imported_at FROM orchestration_v2_legacy_","db.connection":"writer","db.lock_wait_ms":20820.24}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"1ce09e644dafc64a","parentSpanId":"5a8787d23760e14b","startUtc":"16:08:16.925","durationMs":0.0,"exit":"Success","attributes":{"db.query.text":"SELECT MAX(sequence) AS sequence FROM orchestration_events INDEXED BY ","db.connection":"writer","db.lock_wait_ms":0.003}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"03a686708fe2c516","parentSpanId":"5a8787d23760e14b","startUtc":"16:08:16.925","durationMs":0.2,"exit":"Success","attributes":{"db.query.text":"SELECT COUNT(*) AS \"eventCount\", COALESCE(SUM(octet_length(payload_jso","db.connection":"writer","db.lock_wait_ms":0.003}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"d44e2555510011b5","parentSpanId":"5a8787d23760e14b","startUtc":"16:08:16.926","durationMs":0.2,"exit":"Success","attributes":{"db.query.text":"SELECT sequence, event_id, command_id, aggregate_kind, stream_id, even","db.connection":"writer","db.lock_wait_ms":0.002}}
    {"name":"OrchestrationEventStore.rowToV2StoredEvent","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"afc9a33a03b394d2","parentSpanId":"5a8787d23760e14b","startUtc":"16:08:16.926","durationMs":0.2,"exit":"Success","attributes":{}}
    {"name":"orchestrationV2.EventSink.write","traceId":"60017b8f99a0d77f03428801a7fcbc63","spanId":"127973917b38b7a6","parentSpanId":"ecc8e491d0a385db","startUtc":"15:41:49.629","durationMs":130511.0,"exit":"Success","attributes":{"orchestration_v2.event_count":1,"orchestration_v2.thread_id":"mcp:438c3b30-5206-4f9f-be07-e45ee3b319b9"}}
    {"name":"sql.transaction","traceId":"60017b8f99a0d77f03428801a7fcbc63","spanId":"af5491f9012992b0","parentSpanId":"127973917b38b7a6","startUtc":"15:41:49.629","durationMs":130509.8,"exit":"Success","attributes":{"db.connection":"writer","db.lock_wait_ms":42.619}}
    {"name":"orchestrationV2.dispatch.withReceipt","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"040ca4acdedc5ca3","parentSpanId":"c3f201885a317d21","startUtc":"15:41:52.775","durationMs":127698.8,"exit":"Success","attributes":{"orchestration_v2.command_type":"thread.visit","orchestration_v2.thread_id":"f46885a7-859a-46c3-a9ee-31b4e85bda71"}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"44ba795006414fd4","parentSpanId":"040ca4acdedc5ca3","startUtc":"15:41:52.775","durationMs":127694.4,"exit":"Success","attributes":{"db.query.text":"SELECT command_id AS \"commandId\", aggregate_kind AS \"aggregateKind\", a","db.connection":"writer","db.lock_wait_ms":127687.489}}
    {"name":"orchestrationV2.dispatch.once","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"914591d654dcb636","parentSpanId":"040ca4acdedc5ca3","startUtc":"15:44:00.469","durationMs":1.1,"exit":"Success","attributes":{"orchestration_v2.command_type":"thread.visit","orchestration_v2.thread_id":"f46885a7-859a-46c3-a9ee-31b4e85bda71"}}
    {"name":"orchestrationV2.dispatch.threadVisit","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"729a7d55416fa584","parentSpanId":"914591d654dcb636","startUtc":"15:44:00.469","durationMs":1.0,"exit":"Success","attributes":{}}
    {"name":"ProjectionStore.getThread","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"a417d8d29803b0c1","parentSpanId":"729a7d55416fa584","startUtc":"15:44:00.470","durationMs":0.8,"exit":"Success","attributes":{}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"dae16cafa49ede2c","parentSpanId":"a417d8d29803b0c1","startUtc":"15:44:00.470","durationMs":0.2,"exit":"Success","attributes":{"db.query.text":"SELECT payload_json FROM orchestration_v2_projection_threads WHERE thr","db.connection":"writer","db.lock_wait_ms":0.011}}
    {"name":"orchestrationV2.EventSink.commitCommand","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"0a94ce3f25cb9ca7","parentSpanId":"040ca4acdedc5ca3","startUtc":"15:44:00.471","durationMs":3.0,"exit":"Success","attributes":{}}
    {"name":"sql.transaction","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"3b57b7ec4998807a","parentSpanId":"0a94ce3f25cb9ca7","startUtc":"15:44:00.471","durationMs":2.3,"exit":"Success","attributes":{"db.connection":"writer","db.lock_wait_ms":0.05}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"0501d7f17897a01a","parentSpanId":"3b57b7ec4998807a","startUtc":"15:44:00.471","durationMs":0.1,"exit":"Success","attributes":{"db.query.text":"INSERT INTO orchestration_command_receipts ( command_id, aggregate_kin"}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"8c26506d0e9595e8","parentSpanId":"3b57b7ec4998807a","startUtc":"15:44:00.471","durationMs":0.4,"exit":"Success","attributes":{"db.query.text":"INSERT INTO orchestration_events ( event_id, aggregate_kind, stream_id"}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"6f127112cc70cc10","parentSpanId":"3b57b7ec4998807a","startUtc":"15:44:00.472","durationMs":0.2,"exit":"Success","attributes":{"db.query.text":"INSERT INTO orchestration_v2_projection_threads ( thread_id, project_i"}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"d6ef01eb12111fef","parentSpanId":"3b57b7ec4998807a","startUtc":"15:44:00.473","durationMs":0.0,"exit":"Success","attributes":{"db.query.text":"INSERT INTO orchestration_v2_projection_metadata ( projection_name, sc"}}
    {"name":"EffectOutbox.enqueue","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"a0f0510fd7460ef1","parentSpanId":"3b57b7ec4998807a","startUtc":"15:44:00.473","durationMs":0.0,"exit":"Success","attributes":{}}
    {"name":"sqlite","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"bcc6e7376de32600","parentSpanId":"3b57b7ec4998807a","startUtc":"15:44:00.473","durationMs":0.1,"exit":"Success","attributes":{"db.query.text":"INSERT INTO orchestration_command_receipts ( command_id, aggregate_kin"}}
    {"name":"EffectOutbox.signalCancellations","traceId":"377cd81fce563db9a68882322ca92e2d","spanId":"359694e5c8636831","parentSpanId":"0a94ce3f25cb9ca7","startUtc":"15:44:00.473","durationMs":0.0,"exit":"Success","attributes":{}}
  4. juliusmarminge removed labelsneeds more info

  5. Tested main 6e79211743 in Chromium and Linux Electron 44.9.3 under Xvfb, using isolated state. With 5,001 unarchived synthetic threads (4,980 settled, shelf collapsed) and 1,471 PR links on 793 threads, ten warm desktop opens took 299–404 ms (median 335 ms). A 160-command metadata-update burst across 20 threads gave 323–1,232 ms; after archiving 4,800 threads, ten warm opens took 253–454 ms (median 280 ms). Measurements run from sidebar click through the target empty conversation and two animation frames.

    The legacy lookup identified in your October 22 trace now uses the reader connection, landed in 6ed47b538c via #23902. The existing shell-read-while-writer-held regression passes on current main. This does not establish that all reported stalls are fixed: the fixture has empty histories, and the metadata burst does not reproduce 39 queued/running provider runs or the 1.4 GB IndexedDB blob store.

    Please attach a sanitized trace of one slow open from a nightly containing that commit, including the build, timestamp and concurrent run count. That will show which delays remain after the reader-routing change. No database or credentials needed.

    Runtime transcript and all timing samples · Recorded desktop opens with timestamps

    Reproduction scripts

    Thread seed, PR-link seed, archive comparison, open driver, recording driver, metadata-load driver.

  6. juliusmarminge added labelsneeds more info

  7. Note

    🤖 Claude Opus 5.5 responding on behalf of Theo

    Addressed by #24723. The shell now keeps only the newest settled threads and loads older ones on demand, so client work no longer scales with every settled thread. Reopen with a fresh trace if opens are still slow on a build with #24723.

Sign in to join this conversation.