Skip to content

overview -p today crashes with heap OOM on large corpora (cache-load layer) #1504

Closed

Description

@iliaal

Problem

codeburn overview -p today crashes with a V8 heap OOM on large session corpora:

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
exit:134

Repro (reporter corpus, ~1.2GB session-cache shards, 410MB+ same-day sources):

NODE_OPTIONS="--no-deprecation --max-old-space-size=512" npx tsx src/cli.ts overview -p today

The run dies at ~512MB heap after ~5 minutes. Uncapped runs survive but retain ~1.46GB in the load phase alone.

Root causes (cache-I/O layer)

  1. Ranged loads assembled whole multi-hundred-MB month shards (loadShardMemoized whole-parsed via JSON.parse), including a 578MB shard that exceeds V8's max string length.
  2. The pre-lock snapshot overlapped the canonical reload (~787MB duplicate live at once).
  3. Lock publishes rewrote the entire result file; codex discovery re-decoded the result cache per directory.
  4. Retained strings were tokenizer slices pinning whole input chunks (~1.2GB phantom heap on this corpus).
  5. Cross-provider dedup held full raw keys; provider queries scanned unrelated sections.

Fix

PR #1502 (branch fix/oom-bounded-shard-load):

  • Session month shards decode incrementally, one turn at a time, keeping only in-range turns (same kept/dropped/carry contract).
  • Codex result cache streams instead of whole-parsing; discovery labels served from calls-free metadata; publishes merge instead of full rewrite.
  • Shard loads run serially; pre-lock snapshot released before reload.
  • Retained strings detached from tokenizer buffers; dropped dedup keys are 128-bit digests; provider-scoped queries skip unrelated sections.
  • Codex single-flight loads retry on publish-generation change; clear path bumps a global epoch.

Verification

  • npm test: full suite green; npm run test:locks: 36/36; tsc --noEmit clean.
  • Load-phase retention measured 1.46GB -> 232MB on the reporter corpus.
  • New suites: range-filter (incl. 30k-turn record test), shard-stream, codex-range-filter, concurrent-publish gate, digest/marker tests.

Note: this fixes the load phase only. The same-day parse still retains ~1-2GB of full turns (see follow-up issue for the aggregate-mode fix).

Activity

  1. added
    bug
    area: cli
    status: has-pr
    on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: clibugstatus: has-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions