perf: cheaper ingest — no re-parse of live hooked transcripts, delta hook writes, lighter pollers
- Session sync leaves a transcript alone while hooks feed its session live (active, newest event a hook's, touched within DASHBOARD_SYNC_LIVE_HOOK_MS, default 5 min) and catches it up once quiet; a hook-created session (which importSession skips anyway) is only snapshotted, never parsed. - Hook writer keeps a per-transcript mark (applied after commit): an unchanged TranscriptCache result skips token/compaction/API-error/turn writes, a grown one walks only the entries after the last one handled. - Codex usage: one stamp query per pass instead of one row per journal; between full passes (first + every 5 min) only the newest day folders and journals written in the last hour are statted; fork parents resolved from the table or a full walk. - Cursor/Antigravity polls back off to 60 s after idle passes (server/lib/backoff-poll.js); lane sync runs only while another dashboard shares the data dir (checked every 30 s).
This commit is contained in:
+21
-4
@@ -825,18 +825,35 @@ function startBackgroundServices() {
|
||||
}
|
||||
// Another dashboard on the same database (hooks reach only one of them)
|
||||
// moving a lane: re-broadcast it here. One pragma per beat when nothing
|
||||
// changed. Off with DASHBOARD_LANE_SYNC_MS=0.
|
||||
// changed — and only while such a dashboard runs at all: alone on its data
|
||||
// dir, this server only looks for one every LANE_PEER_CHECK_MS (the first
|
||||
// call primes what it has seen, so a peer that starts later is compared
|
||||
// against it). Off with DASHBOARD_LANE_SYNC_MS=0.
|
||||
const LANE_SYNC_MS = Number(process.env.DASHBOARD_LANE_SYNC_MS ?? 2_000);
|
||||
if (Number.isFinite(LANE_SYNC_MS) && LANE_SYNC_MS > 0) {
|
||||
const { broadcastForeignLaneChanges } = require("./routes/lanes");
|
||||
const laneSyncTimer = setInterval(() => {
|
||||
const LANE_PEER_CHECK_MS = Math.max(LANE_SYNC_MS, 30_000);
|
||||
let peersSeenAt = 0;
|
||||
let hasPeers = false;
|
||||
const syncLanes = () => {
|
||||
try {
|
||||
broadcastForeignLaneChanges();
|
||||
} catch (err) {
|
||||
console.warn("lane sync failed:", err.message);
|
||||
}
|
||||
}, LANE_SYNC_MS);
|
||||
if (laneSyncTimer.unref) laneSyncTimer.unref();
|
||||
};
|
||||
syncLanes();
|
||||
const laneSyncTick = () => {
|
||||
if (Date.now() - peersSeenAt >= LANE_PEER_CHECK_MS) {
|
||||
hasPeers = peersSharingDataDir().length > 0;
|
||||
peersSeenAt = Date.now();
|
||||
}
|
||||
if (hasPeers) syncLanes();
|
||||
const t = setTimeout(laneSyncTick, hasPeers ? LANE_SYNC_MS : LANE_PEER_CHECK_MS);
|
||||
if (t.unref) t.unref();
|
||||
};
|
||||
const first = setTimeout(laneSyncTick, LANE_SYNC_MS);
|
||||
if (first.unref) first.unref();
|
||||
}
|
||||
// Continuous discovery of sessions under ~/.claude/projects. The one-time
|
||||
// legacy backfill above runs only once (marker-gated), so a project added
|
||||
|
||||
Reference in New Issue
Block a user