优化 / 高 / 后端服务
electron/services/session-recorder.service.ts
SessionRecorder 使用 fs.appendFileSync 同步写入 trace 文件。 流式事件频率 30-50 次/秒,每次 IO 阻塞主进程 1-5ms,累计:
fs.appendFileSync
private buffer: string[] = []; private flushTimer: NodeJS.Timeout | null = null; record(event) { this.buffer.push(JSON.stringify(event)); if (!this.flushTimer) { this.flushTimer = setTimeout(() => this.flush(), 100); } } private async flush() { if (this.buffer.length === 0) return; const data = this.buffer.join('\n') + '\n'; this.buffer = []; this.flushTimer = null; await fs.promises.appendFile(this.filePath, data); }
No dependencies set.
The note is not visible to the blocked user.
问题类型
优化 / 高 / 后端服务
文件位置
electron/services/session-recorder.service.ts问题描述
SessionRecorder 使用
fs.appendFileSync同步写入 trace 文件。流式事件频率 30-50 次/秒,每次 IO 阻塞主进程 1-5ms,累计:
影响
建议修复