mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-05 06:59:42 +02:00
perf: optimize for long-running Claude sessions
Critical fixes (unbounded growth): - Add 64KB line buffer limit with 100ms periodic flush in session.ts - Add task tracker cleanup (max 100 completed tasks) - Add scheduled runs auto-cleanup after 1 hour - Fix session leaks in scheduled run iterations High priority (performance): - Add SSE event batching (50ms output, 100ms task updates) - Parallelize screen stats with Promise.all() - Add 1MB buffer limit to respawn controller Medium priority (frontend): - Make xterm scrollback configurable (default 5000) - Debounce renderSessionTabs() at 100ms New feature: - Add CPU and memory usage display in frontend header - New /api/system/stats endpoint Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { Session } from './session.js';
|
||||
|
||||
// Maximum terminal buffer size for respawn controller (1MB)
|
||||
const MAX_RESPAWN_BUFFER_SIZE = 1024 * 1024;
|
||||
// Keep this much when trimming (512KB)
|
||||
const RESPAWN_BUFFER_TRIM_SIZE = 512 * 1024;
|
||||
|
||||
/**
|
||||
* Respawn sequence states
|
||||
*
|
||||
@@ -182,9 +187,9 @@ export class RespawnController extends EventEmitter {
|
||||
private handleTerminalData(data: string): void {
|
||||
this.terminalBuffer += data;
|
||||
|
||||
// Keep buffer manageable (last 10KB)
|
||||
if (this.terminalBuffer.length > 10240) {
|
||||
this.terminalBuffer = this.terminalBuffer.slice(-5120);
|
||||
// Keep buffer manageable (max 1MB, trim to 512KB)
|
||||
if (this.terminalBuffer.length > MAX_RESPAWN_BUFFER_SIZE) {
|
||||
this.terminalBuffer = this.terminalBuffer.slice(-RESPAWN_BUFFER_TRIM_SIZE);
|
||||
}
|
||||
|
||||
// Filter out noise - only count meaningful data as activity
|
||||
|
||||
Reference in New Issue
Block a user