-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Description
Problem
The readRecentCandidates() function in src/gep/assetStore.js reads the entire candidates.jsonl file into memory, even though it only needs the last N lines:
function readRecentCandidates(limit = 20) {
const raw = fs.readFileSync(p, 'utf8'); // Reads ENTIRE file!
const lines = raw.split('\n').map(l => l.trim()).filter(Boolean);
return lines.slice(Math.max(0, lines.length - limit))...
}Impact
When candidates.jsonl grows large (my file reached 83MB), this causes:
- Memory spike during each evolution cycle
- Potential OOM crash when combined with other memory usage
- Process restart/killed by the suicide check (
EVOLVER_MAX_RSS_MB)
Reproduction
- Run evolver for an extended period (weeks/months)
candidates.jsonlaccumulates to tens of MB- Observe memory usage spike or process crash
Suggested Fix
Use streaming or tail approach to only read the last N lines:
function readRecentCandidates(limit = 20) {
const { execSync } = require('child_process');
try {
const output = execSync(`tail -n ${limit} "${p}"`, { encoding: 'utf8', timeout: 5000 });
return output.split('\n').filter(Boolean).map(l => {
try { return JSON.parse(l); } catch { return null; }
}).filter(Boolean);
} catch { return []; }
}Or implement a proper backwards file reader for Windows compatibility.
Environment
- evolver version: v1.27.5
- Node.js: v20.x
- OS: Linux
candidates.jsonlsize: 83MB (before cleanup)
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels