[Bug]: Thread opens take seconds with ~5,000 unarchived threads; client work scales with every settled thread in the shell #22372
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#
- 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. - Open any thread from the desktop sidebar while about 20 runs are active.
- Compare the client spans that the desktop app exports into
server.trace.ndjsonwith the server'shttp.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:
| Span | n | p50 | p95 | max |
|---|---|---|---|---|
http.orchestration.loadThreadSnapshotWindow (server) | 66 | 14 ms | 124 ms | 376 ms |
EnvironmentThreadState.make | 88 | 0 ms | 208 ms | 3,142 ms |
web.connectionStorage.readDatabaseValue | 53 | 41 ms | 439 ms | 3,012 ms |
EnvironmentCommands.visitThread | 63 | 266 ms | 3,792 ms | 10,763 ms |
storage.saveShell | 222 | 176 ms | 559 ms | 1,504 ms |
storage.saveThread | 113 | 102 ms | 1,013 ms | 3,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:
| Span | max before | max after |
|---|---|---|
web.connectionStorage.readDatabaseValue | 3,012 ms | 48 ms |
EnvironmentThreadState.make | 3,142 ms | 76 ms |
EnvironmentCommands.visitThread | 10,763 ms | 221 ms |
storage.saveShell | 1,504 ms | 244 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:findplusupsertById(findIndexandmap) produce a new N-element array for eachthread.updated.Sidebar.tsx:457subscribes to all thread shells. Each render runspartitionSidebarThreads(:601-692), which filters, builds keys, and sorts withDate.parseandlocaleCompareacross all N threads, even when the settled shelf is collapsed to 10 rows.- The derived atoms in
threadShell.ts(:64,:170,:195,:210,:376) anduseThreadVisitedMigration.ts:19-39each iterate all threads. saveShellstill writes the whole shell to IndexedDB about every 10.5 s, throughcachePersistence.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.
juliusmarminge added labelsneeds more info
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 (latest20261022.3526, f054d1b80187). I didn't upgrade with runs in progress. The code path below is identical in f054d1b80187 and onmain.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.sqliteis 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:
readDatabaseValuep50 is 46 ms (max 1,066 ms), andEnvironmentThreadState.makep50 is 10 ms. Opens are still slow. FromEnvironmentThreadState.maketo the firstapplyItemsfromsubscribeThread: 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.subscribeThreadrunsensureLegacyTranscriptfirst.LegacyV1ThreadImporter.ts:684-700adds a thread toconfirmedTranscriptThreadIdsonly when it has anorchestration_v2_legacy_importsrow. On this install that table has 0 rows, so no thread ever takes the fast path. Every open, and every command that callsensureCommandTranscripts, takes the per-thread lock and runs the lookup, and the spans show that lookup ondb.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 oneSELECT's lock wait; the writer was held bypublishThreadUnsafefor 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.subscribeThreadand the server'sws.rpc.orchestration.subscribeThreadstarting. 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, threadmcp: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 athread.visitfor f46885a7 (127.7 s lock wait, then 1 ms of work), scheduled-task dispatch andensureLegacyTranscript(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
subscribeThreadcalls 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) thread IndexedDB read client sends subscribe → server handler starts server initial sync of which ensureLegacyTranscriptits writer lock wait open → first data applied 15:35:57.199 mcp:93209a2b-8945-484e-983e-f3a8568868ef 42 ms 1,261 ms 6 ms 0 ms 0 ms 1,574 ms 15:37:17.572 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 66 ms 219 ms 54 ms 0 ms 0 ms 545 ms 15:37:19.974 mcp:6bbb1667-3295-4632-aee8-918506e53570 12 ms 31 ms 54 ms 0 ms 0 ms 382 ms 15:38:32.637 mcp:da2d7742-3648-4d7f-a627-aa29f61c46ff 46 ms 6 ms 2 ms 1 ms 0 ms 196 ms 15:38:45.642 (delegated-task thread) 10 ms 415 ms 1,426 ms 1,424 ms 0 ms 2,659 ms 15:38:51.076 (delegated-task thread) 3 ms 2,727 ms 1 ms 0 ms 0 ms 5,389 ms 15:40:48.021 mcp:6bbb1667-3295-4632-aee8-918506e53570 930 ms 11 ms 0 ms 0 ms 2,887 ms 15:44:22.669 9a4f1ef5-3088-4e96-8c3b-6c0c27cd6be8 22 ms 434 ms 2,606 ms 2,598 ms 1,323 ms 6,900 ms 15:44:29.299 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 67 ms 147 ms 1,459 ms 1,384 ms 1,227 ms 2,038 ms 15:44:31.007 mcp:600d2dcb-c555-4c6b-bc16-7a520852b255 71 ms 1,081 ms 1,078 ms 269 ms 1,219 ms 15:44:46.794 (delegated-task thread) 6 ms 52 ms 35 ms 34 ms 34 ms 590 ms 15:44:47.637 (delegated-task thread) 5 ms 119 ms 1 ms 0 ms 0 ms 247 ms 15:45:38.006 mcp:93209a2b-8945-484e-983e-f3a8568868ef 1,301 ms 4,869 ms 4,865 ms 4,865 ms 8,472 ms 15:45:38.006 mcp:93209a2b-8945-484e-983e-f3a8568868ef 1,300 ms 4,869 ms 4,865 ms 4,865 ms 4,518 ms 15:46:12.523 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 4,247 ms 1,703 ms 1,517 ms 902 ms 6,545 ms 15:46:37.476 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 628 ms 1,744 ms 1,741 ms 1,138 ms 3,114 ms 15:47:19.365 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 1,220 ms 1,955 ms 1,952 ms 1,247 ms 3,785 ms 15:47:47.262 mcp:ee047d92-bfe0-4e4a-982e-2ad6d622a5ba 142 ms 1,349 ms 6,498 ms 6,495 ms 3,360 ms 9,455 ms 15:48:09.063 mcp:2094f738-8855-4fde-8b20-a5ceb4dee053 51 ms 715 ms 6 ms 0 ms 0 ms 2,025 ms 15:49:10.528 mcp:600d2dcb-c555-4c6b-bc16-7a520852b255 1,659 ms 5 ms 0 ms 0 ms 1,846 ms 15:49:30.807 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 20 ms 82 ms 3 ms 0 ms 0 ms 2,489 ms 15:49:31.639 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 401 ms 3 ms 0 ms 0 ms 569 ms 15:49:33.220 (delegated-task thread) 23 ms 481 ms 2 ms 0 ms 0 ms 680 ms 15:52:04.892 49fc2384-af68-4d04-b2ec-4b7a50bb8b48 17 ms 5,519 ms 1 ms 0 ms 0 ms 6,905 ms 15:54:01.218 mcp:600d2dcb-c555-4c6b-bc16-7a520852b255 5 ms 7 ms 0 ms 0 ms 141 ms 15:54:02.127 (delegated-task thread) 8 ms 36 ms 2 ms 0 ms 0 ms 362 ms 15:54:02.486 (delegated-task thread) 3 ms 65 ms 2 ms 0 ms 0 ms 223 ms 15:54:40.919 mcp:57c7a8a5-b75d-4a3a-8c9c-624259f52936 204 ms 8 ms 6 ms 0 ms 0 ms 297 ms 15:55:29.983 mcp:600d2dcb-c555-4c6b-bc16-7a520852b255 41 ms 106 ms 4 ms 0 ms 0 ms 10,523 ms 15:55:52.662 mcp:6ef76b38-f76c-4acd-aeba-9bc480d1dd01 103 ms 4,889 ms 20 ms 1 ms 0 ms 5,214 ms 15:56:07.367 mcp:fa047391-785c-454e-9cdf-a3c257aa8e93 148 ms 4,443 ms 21 ms 0 ms 0 ms 4,885 ms 15:56:31.614 49fc2384-af68-4d04-b2ec-4b7a50bb8b48 269 ms 46 ms 0 ms 0 ms 525 ms 15:56:38.316 mcp:12e85481-132e-4a40-b21c-03e3fd258249 247 ms 2,083 ms 46 ms 0 ms 0 ms 2,512 ms 15:58:31.608 (delegated-task thread) 6 ms 26 ms 1 ms 0 ms 0 ms 187 ms 15:58:32.782 (delegated-task thread) 1 ms 351 ms 1 ms 0 ms 0 ms 969 ms 15:59:30.443 mcp:a580e409-9a0d-44be-8de0-f287c34875ed 1,066 ms 2 ms 18 ms 0 ms 0 ms 1,679 ms 15:59:40.903 mcp:bfdca20d-9b14-443a-9c88-d9c9031e2908 175 ms 3 ms 8 ms 0 ms 0 ms 457 ms 15:59:47.563 mcp:17acd3f5-cb05-4d06-870e-df3f294bb691 128 ms 37 ms 8 ms 0 ms 0 ms 589 ms 15:59:55.655 1aa7b3eb-705e-4931-b6fd-38e7a6a9a715 2,211 ms 6 ms 0 ms 0 ms 2,860 ms 16:00:01.025 1aa7b3eb-705e-4931-b6fd-38e7a6a9a715 3,920 ms 2 ms 0 ms 0 ms 3,990 ms 16:00:14.682 mcp:ed3f394b-b11d-4e90-909c-f467d60ce2e9 52 ms 387 ms 10 ms 1 ms 0 ms 567 ms 16:00:20.420 mcp:8205f851-f7da-4a03-b8f1-3dc903ca97f9 67 ms 19 ms 4 ms 0 ms 0 ms 289 ms 16:00:32.531 mcp:bf6220ee-eab2-4c24-84d1-913c944d7572 168 ms 212 ms 10 ms 1 ms 0 ms 486 ms 16:00:42.051 (delegated-task thread) 41 ms 34 ms 4 ms 0 ms 0 ms 156 ms 16:00:43.147 (delegated-task thread) 1 ms 125 ms 4 ms 0 ms 0 ms 416 ms 16:00:52.784 mcp:6bbb1667-3295-4632-aee8-918506e53570 144 ms 130 ms 4 ms 0 ms 0 ms 358 ms 16:00:54.084 mcp:bf6220ee-eab2-4c24-84d1-913c944d7572 13 ms 4 ms 0 ms 0 ms 81 ms 16:00:59.679 mcp:6bbb1667-3295-4632-aee8-918506e53570 17 ms 4 ms 0 ms 0 ms 166 ms 16:01:05.038 mcp:93209a2b-8945-484e-983e-f3a8568868ef 228 ms 104 ms 4 ms 0 ms 0 ms 624 ms 16:01:32.753 mcp:438c3b30-5206-4f9f-be07-e45ee3b319b9 76 ms 6,855 ms 8 ms 0 ms 0 ms 7,369 ms 16:01:52.813 mcp:ee047d92-bfe0-4e4a-982e-2ad6d622a5ba 169 ms 6,785 ms 5 ms 0 ms 0 ms 7,677 ms 16:02:09.161 9a4f1ef5-3088-4e96-8c3b-6c0c27cd6be8 46 ms 5,245 ms 97 ms 0 ms 0 ms 5,833 ms 16:03:18.475 49fc2384-af68-4d04-b2ec-4b7a50bb8b48 73 ms 1,930 ms 5 ms 1 ms 0 ms 2,483 ms 16:03:24.127 (delegated-task thread) 2 ms 2,869 ms 3 ms 1 ms 0 ms 3,808 ms 16:04:24.356 mcp:411327df-0143-4a81-94ee-a9669a6e4750 72 ms 5,019 ms 12 ms 0 ms 0 ms 5,332 ms 16:04:40.453 mcp:12e85481-132e-4a40-b21c-03e3fd258249 215 ms 1 ms 0 ms 0 ms 235 ms 16:05:04.213 mcp:93209a2b-8945-484e-983e-f3a8568868ef 62 ms 2 ms 0 ms 0 ms 227 ms 16:06:05.458 (delegated-task thread) 21 ms 2,862 ms 1,840 ms 1,835 ms 1,835 ms 5,792 ms 16:06:13.358 (delegated-task thread) 1 ms 1,437 ms 11 ms 1 ms 0 ms 3,710 ms 16:06:28.521 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 360 ms 96 ms 46 ms 0 ms 0 ms 1,386 ms 16:07:23.032 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 336 ms 157 ms 151 ms 126 ms 1,065 ms 16:07:56.093 49fc2384-af68-4d04-b2ec-4b7a50bb8b48 2 ms 20,821 ms 20,820 ms 20,820 ms 21,003 ms 16:08:38.301 49fc2384-af68-4d04-b2ec-4b7a50bb8b48 1,306 ms 8 ms 0 ms 0 ms 5,150 ms 16:09:08.557 7f3a0adc-2f56-4ffa-8919-ae72c3ab3952 657 ms 1,752 ms 1,750 ms 1,329 ms 2,709 ms 16:09:11.728 (delegated-task thread) 8 ms 1,091 ms 2 ms 0 ms 0 ms 1,936 ms 16:09:14.369 (delegated-task thread) 1 ms 1,452 ms 1 ms 0 ms 0 ms 3,234 ms 16:10:01.531 9a4f1ef5-3088-4e96-8c3b-6c0c27cd6be8 9,842 ms 3 ms 0 ms 0 ms 10,020 ms 16:10:24.874 mcp:6eed729f-d315-4f11-becb-fa72a9aedaeb 17 ms 60 ms 5 ms 0 ms 0 ms 130 ms 16:10:38.883 49fc2384-af68-4d04-b2ec-4b7a50bb8b48 294 ms 1 ms 0 ms 0 ms 3,745 ms 16:11:49.105 mcp:93209a2b-8945-484e-983e-f3a8568868ef 1,157 ms 11 ms 1 ms 0 ms 1,239 ms 16:11:51.512 mcp:a580e409-9a0d-44be-8de0-f287c34875ed 72 ms 109 ms 11 ms 1 ms 0 ms 747 ms 16:12:55.233 (delegated-task thread) 53 ms 74 ms 2 ms 0 ms 0 ms 305 ms 16:15:22.916 mcp:12e85481-132e-4a40-b21c-03e3fd258249 58 ms 855 ms 19 ms 0 ms 0 ms 1,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 msSanitized 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 torpc.method, thread ids, command type,db.connection,db.lock_wait_msand 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":{}}- 7 waited on the SQLite writer inside
juliusmarminge removed labelsneeds more info
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.
juliusmarminge added labelsneeds more info
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
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.