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
longjucheng
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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