You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three low-severity costs found together. Each is independent.
Details
attach() is O(items x segments) (src/utils/recordingIndex.ts:305-309). Items are sorted, but each one runs out.findIndex(...) from the start. With 50k log lines and 10k events against 600 segments, that is about 3.6e7 predicate calls, synchronous during index_recording. Fix: walk a segment cursor forward (two-pointer) or binary-search the segment starts.
save_replay writes the buffered footage three times (src/utils/replay.ts:278-282, 308-310, 319-329): it copies the segments to snap/, concat-copies them to joined.mp4, then stream-copies with -ss into the output. Saving a 1 h 4K buffer writes about 3x its size and needs 3x temporary space. Fix: if the measurements in save_replay copies up to an hour of segments synchronously and writes the footage 3x #293 allow it, fold the cut into the final step; otherwise drop the separate copy when the segments are no longer being written.
Server startup blocks on PowerShell when another instance is recording (src/index.ts:34-36, 55-56, src/utils/sessions.ts:232-243). reapOrphans() runs before server.connect, and processInfo does a spawnSync PowerShell CIM query (up to 10 s) for each foreign live pid. A second client starting while the first records waits 1-10 s before initialize is answered. Fix: connect first and reap right after (as retention pruning already does, Retention prune walks capture folders synchronously before the transport connects #294), or make processInfo async.
Getting started
Relevant files: listed per item
How to run tests: npm test
Filed by repo-audit/full-audit at b9b94fa. Severity: low. Effort: M. audit-key: performance|src/utils/recordingIndex.ts|attach
1bae732 fixes the attach() scan. Left as is, with reasons:
Startup reaping before connect: moving it after server.connect does not help on its own, since the synchronous reap still runs before initialize is handled. Deferring it further would let a fresh start_recording from this server land first, and the reaper could then classify that new, own recording as an orphan. A safe version needs reaping restricted to the records that existed at boot, or an async processInfo. It only costs time when another instance is recording, so it stays open for that.
e596700 fixes the startup item. The server snapshots the live record ids and replay buffer names, connects, and then reconciles in the background. It reads the owners' details with an async processInfo and reaps only the boot ids, so a recording started meanwhile is never taken for an orphan. Verified: new tests for boot-only reaping, a foreign live owner left alone, processInfoAsync, and replay cleanup limited to the boot snapshot; the full suite passes; a built server answers initialize in about 400 ms. Still open: the save_replay triple write, which stays until a variant measures frame-equivalent (#293).
Two of the three items are fixed: the attach() scan (1bae732) and startup reaping (e596700). The save_replay triple write stays on purpose: #293 measured the single-pass alternatives and they were not frame-equivalent. Closing; a new issue can track it if a variant is measured equal.
Activity
perf(index): binary-search the segment for each attached item (#358)
TMHSDigital commentedon Nov 17, 2026
1bae732 fixes the attach() scan. Left as is, with reasons:
server.connectdoes not help on its own, since the synchronous reap still runs beforeinitializeis handled. Deferring it further would let a freshstart_recordingfrom this server land first, and the reaper could then classify that new, own recording as an orphan. A safe version needs reaping restricted to the records that existed at boot, or an asyncprocessInfo. It only costs time when another instance is recording, so it stays open for that.perf(startup): reap orphans after connecting, without blocking (#358)
TMHSDigital commentedon Nov 18, 2026
e596700 fixes the startup item. The server snapshots the live record ids and replay buffer names, connects, and then reconciles in the background. It reads the owners' details with an async processInfo and reaps only the boot ids, so a recording started meanwhile is never taken for an orphan. Verified: new tests for boot-only reaping, a foreign live owner left alone, processInfoAsync, and replay cleanup limited to the boot snapshot; the full suite passes; a built server answers initialize in about 400 ms. Still open: the save_replay triple write, which stays until a variant measures frame-equivalent (#293).
test(sessions): give the PowerShell-backed #358 tests 30 s
TMHSDigital commentedon Nov 19, 2026
Two of the three items are fixed: the attach() scan (1bae732) and startup reaping (e596700). The save_replay triple write stays on purpose: #293 measured the single-pass alternatives and they were not frame-equivalent. Closing; a new issue can track it if a variant is measured equal.