Repository navigation
Bug: persistence.list() walks every session directory one libuv round-trip at a time (~2.3k event-loop turns per call), and session_trace has no timeoutMs
#8631
Replies: 1 comment
|
I reproduced the full-store authorization cost described above through The reproduction used 2,441 synthetic JSONL sessions, a small live search target, and 40 simultaneous tool calls (20 targeted searches and 20 reads by event sequence). The query selects one known hit in the live target. With the deployed baseline, all 20 searches timed out during I tested a small change in the shared session-query service. A filter containing one exact session ID resolves metadata through the live store and I repeated the same 40-call workload twice with only the shared session-query module replaced. Across both runs, all 40 searches returned the expected event and all 40 reads returned the expected sequence. Search calls took 13.58–42.74 ms and reads took 11.55–43.42 ms. Each batch made 40 The deployed baseline was |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Three paths list the whole persisted store before their own work, and the listing is strictly sequential:
session_trace→sessionQuery.traceSession→SessionCorpus.listSessions→persistence.list()(packages/session-query/session-query/src/index.ts:327–331,corpus.ts:61–80);session_event_readon a non-caller target →authorizeTarget→filterSessions→ the same listing (packages/session-query/tool-session-query/src/workspace-access.ts:85); thenreadEvent→SessionCorpus.load→ the listing again when the session is not live (session-query/src/index.ts:370);sessionQuery.readSession(id)of a non-live session →SessionCorpus.load→persistence.list()before the one log is read (corpus.ts:91–98).JsonlSessionPersistence.list()(packages/session/session-persistence-jsonl/src/index.ts:475–509) runslistArtifacts(:1056–1084: per directoryreaddir, thenopen+read+zstdDecompress+closefor the header line (readFirstZstdLine,:1410–1444), thenrealpathwhen needed), thenhistoricalCorpusRevision(:1038–1054: a second fulllistGenerationspass plus onestatper log while pre-v4 logs remain), then onestatper artifact. Each step is one libuv round-trip; none run concurrently. Wall time isturns × event-loop turn cost.session_traceis registered withouttimeoutMs(packages/session-query/tool-session-query/src/index.ts:85–93); the two search tools takesearchTimeoutMs. The cost scales with store size × loop delay, not with lineage size.Reproduction (offline, no session content)
Copy of a 228-session, 89 MB store:
list()wall timePer call: ~1.6k
FSREQPROMISE, 228ZLIB, 228FILEHANDLECLOSEREQ, ~2.29k event-loop turns.Current behavior
On a host whose event loop was congested (the heap-growth phase of #7414),
session_trace {}took 447 s (aborted) and 558.7 s (retry, ok);session_event_readon a non-live session took 1428.7 s (two listings). No timeout applies. After a restart the same calls return in under a second.Expected behavior
load's live branch does not;observeSessioncaches one id by revision).session_tracetakestimeoutMslike the search tools.Related: #7414 (comment "Cold-corpus re-enumeration": the same walk measured from the I/O side); #7356 (
readEventdeep-clones the whole session on the live branch; this report is the persisted branch).Environment
@deepseek-ai/dshsource checkout at tagdsh-v0.2.0-rc.1, dev launchpnpm dsh web(node --import tsx/esm apps/cli/src/bin.ts web)session.jsonl.zstd,.v2,.v3) presentAll reactions