perf(session): separate indexed and snapshot log reads

This commit is contained in:
_Kerman
2026-08-28 13:25:58 +08:00
parent 6d38ba8656
commit 5660f44d29
251 changed files with 1371 additions and 1207 deletions
@@ -484,7 +484,7 @@ export class SessionCommandController {
private async readSessionState(sessionId: SessionId): Promise<SessionReadState> {
const attached = this.ctx.sessions.get(sessionId)
if (attached !== undefined) {
return { id: attached.id, header: attached.header, events: [...attached.events] }
return { id: attached.id, header: attached.header, events: [...attached.snapshotEvents()] }
}
const inspected = await inspectApiSession(this.ctx, sessionId)
return { id: inspected.meta.id, header: inspected.meta, events: inspected.events }
@@ -112,7 +112,7 @@ export class SessionHistoryController {
// Constructor seed events have no session/event notification. Normally
// only the end-seed suffix is new; if persistence advanced after the
// opening observation, replay everything beyond that snapshot cursor.
const suffix = session.events.slice(snapshotCursor === undefined
const suffix = session.snapshotEvents(snapshotCursor === undefined
? session.firstLiveSeq
: snapshotCursor + 1)
buffered.unshift(...suffix)
+1 -1
View File
@@ -194,7 +194,7 @@ export class SessionController extends TypertRemoteService {
): Promise<{ meta: SessionHeader; events: SessionEvent[] }> {
const attached = this.ctx.sessions.get(sessionId)
if (attached !== undefined) {
return Promise.resolve({ meta: attached.header, events: [...attached.events] })
return Promise.resolve({ meta: attached.header, events: [...attached.snapshotEvents()] })
}
return inspectApiSession(this.ctx, sessionId, signal)
}