perf(server): trace logs keep hours of history instead of minutes #5780
Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromt3code/trace-log-churnopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/server/src/terminal/Manager.ts lines 93 to 102OutdatedResolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -89,10 +90,13 @@8990 "TerminalSubprocessCheckError",9091 {9192 cause: Schema.optional(Schema.Defect()),93+ // 0 when a whole-table snapshot failed rather than a single terminal.9294 terminalPid: Schema.Number,93- command: Schema.Literals(["powershell", "pgrep", "ps"]),95+ command: Schema.Literals(["powershell", "ps"]),9496 },9597 ) {9698 override get message(): string {97- return `Failed to inspect terminal subprocesses for PID ${this.terminalPid} with ${this.command}`;99+ return this.terminalPid > 0100+ ? `Failed to inspect terminal subprocesses for PID ${this.terminalPid} with ${this.command}`101+ : `Failed to capture the process table with ${this.command}`;98102 }
- apps/server/src/terminal/Manager.ts line 640OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -619,9 +626,15 @@626+export function processTableFromRows(627+ rows: Iterable<readonly [pid: number, parentPid: number, command: string]>,628+): ProcessTableSnapshot {629+ const commandByPid = new Map<number, string>();630+ const childrenByParent = new Map<number, number[]>();631+ for (const [pid, parentPid, command] of rows) {632+ commandByPid.set(pid, command);633+ const children = childrenByParent.get(parentPid) ?? [];634+ children.push(pid);635+ childrenByParent.set(parentPid, children);619636 }620- return null;637+ return { commandByPid, childrenByParent };621638 }622639623-function windowsInspectSubprocess(624- terminalPid: number,625- platform: NodeJS.Platform,626-): Effect.Effect<627- TerminalSubprocessInspectResult,640+const PROCESS_TABLE_MAX_OUTPUT_BYTES = 1_048_576;apps/server/src/terminal/Manager.ts line 2012Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2055,0 +1959,21 @@1959+ if (subprocessInspector !== null) {1960+ for (const session of sessions) {1961+ const inspectResult = yield* subprocessInspector(session.pid).pipe(1962+ Effect.map(Option.some),1963+ Effect.catch((reason) =>1964+ Effect.logWarning("failed to check terminal subprocess activity", {1965+ threadId: session.threadId,1966+ terminalId: session.terminalId,1967+ terminalPid: session.pid,1968+ reason,1969+ }).pipe(Effect.as(Option.none<TerminalSubprocessInspectResult>())),1970+ ),1971+ );1972+ if (Option.isSome(inspectResult)) {1973+ results.set(session.pid, inspectResult.value);1974+ }1975+ }1976+ return results;1977+ }1978+1979+ const snapshot = yield* captureProcessTableSnapshot(platform).pipe(
- packages/shared/src/logging.ts line 148OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -118,10 +131,18 @@118131 for (let index = this.maxFiles - 1; index >= 1; index -= 1) {132+ const compressedSource = this.withSuffix(index, "gz");133+ if (NodeFS.existsSync(compressedSource)) {134+ NodeFS.renameSync(compressedSource, this.withSuffix(index + 1, "gz"));135+ }119136 const source = this.withSuffix(index);120- const target = this.withSuffix(index + 1);121137 if (NodeFS.existsSync(source)) {122- NodeFS.renameSync(source, target);138+ NodeFS.renameSync(source, this.withSuffix(index + 1));123139 }124140 }125141126142 if (NodeFS.existsSync(this.filePath)) {127- NodeFS.renameSync(this.filePath, this.withSuffix(1));143+ if (this.compressBackups) {144+ NodeFS.writeFileSync(145+ this.withSuffix(1, "gz"),146+ NodeZlib.gzipSync(NodeFS.readFileSync(this.filePath)),147+ );148+ NodeFS.rmSync(this.filePath, { force: true });
- apps/server/src/terminal/Manager.ts lines 94 to 94OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -90,4 +91,4 @@9091 {9192 cause: Schema.optional(Schema.Defect()),9293 terminalPid: Schema.Number,93- command: Schema.Literals(["powershell", "pgrep", "ps"]),94+ command: Schema.String,
- apps/server/src/terminal/Manager.ts line 2048Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2070,18 +2045,4 @@2070- const terminalPid = session.pid;2071- const inspectResult = yield* subprocessInspector(terminalPid).pipe(2072- Effect.map(Option.some),2073- Effect.catch((reason) =>2074- Effect.logWarning("failed to check terminal subprocess activity", {2075- threadId: session.threadId,2076- terminalId: session.terminalId,2077- terminalPid,2078- reason,2079- }).pipe(Effect.as(Option.none<TerminalSubprocessInspectResult>())),2080- ),2081- );2082-2083- if (Option.isNone(inspectResult)) {2084- return;2085- }2045+ const inspections = yield* inspectRunningSubprocesses(runningSessions);208620462087- const next = inspectResult.value;2047+ const applySubprocessActivity = Effect.fn("terminal.applySubprocessActivity")(function* (2048+ { session, pid: terminalPid }: RunningSessionPoll,
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
45aae989-08d3-4758-aa03-0cf998ae0844You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share