Skip to content

fix(reconcile): stage membership and entity transitions through appenders, not a million-tuple VALUES literal (#558) - #1511

Merged
athvin merged 1 commit into
mainfrom
fix/558-reconcile-memory
Nov 30, 2026
Merged

athvin merged 1 commit into
mainfrom
fix/558-reconcile-memory

Conversation

@athvin

@athvin athvin commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Closes #558

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Reconcile stages membership (__mem_src) and entity transitions (__ent_src) through DuckDB appenders. Before, each was one create … as select * from (values (…), …) with a tuple per record. The declared upserts are unchanged.

Why

The 10M run's reconcile was OOMKilled at 26Gi even after #1508. Locally at 1M records, reconcile peaked at 8.3 GB RSS with only 231k scores, from parsing a million-tuple literal. At 10M that's about 80 GB.

Proof

Release build, #558 corpus and model, /usr/bin/time -l on reconcile alone:

records before after
1M 45.7 s, 8.3 GB 5.1 s, 3.26 GB
2M — 12.6 s, 4.73 GB

About 1.5 GB per million plus 1.8 GB, so about 16.5 GB at 10M, inside class L's 26Gi. make check exit 0, which includes the reconcile goldens and lake e2e. The live proof is the 10M rerun from reconcile onward, recorded in this ledger.

Risk & rollback

Same rows, same statements, different staging. Rollback: git revert <merge-sha>.

Post-merge ledger

Closed by: unclosed

  • main is green with this change on it — the merge SHA, and the run
    that proves it. A later head SHA with this commit as an ancestor counts;
    a cancelled run with zero jobs does not:
  • images built, or correctly never ran because nothing that goes into
    an image changed:
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion:
  • the push-only surface no pull request can pre-test (deploy, drift,
    kind's nightly leg) is green, or knowingly red for a reason that is not
    this change:
  • the board card reached Done through the automation rather than by
    hand, and the issue closed:
  • follow-ups are open for everything deferred here — numbers:
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned:

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

🤖 Generated with Claude Code

…ders, not a million-tuple VALUES literal (#558)

After #1508 capped reconcile's DuckDB at a third of the class limit, the
10M run's reconcile was still OOMKilled at class L's 26Gi, 53 s in.
Measured locally in release with the #558 corpus and model:

  1M records: reconcile 45.7 s, peak RSS 8.3 GB
  (231k scores, so the edges don't explain it)

The cause: reconcile wrote membership as one
'create temp table __mem_src as select * from (values (…), (…), …)'
with a tuple per assigned record, and the entity transitions the same
way (__ent_src). DuckDB parsed a million-tuple literal, a parse tree of
several KB per row, so at 10M about 80 GB.

Both are now created with a schema and filled through a DuckDB appender,
as #1409 did for events. The declared upsert_from_src statements are
unchanged. Measured after:

  1M records: reconcile 5.1 s, peak RSS 3.26 GB
  2M records: reconcile 12.6 s, peak RSS 4.73 GB

That's about 1.5 GB per million plus 1.8 GB, so about 16.5 GB at 10M,
inside class L's 26Gi with reconcile's DuckDB at 6 GB (#1508).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit 61d8961 into main Nov 30, 2026
43 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 30, 2026 13:22 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — 4b0ff155 Deployed Nov 30, 2026 by athvin via remove closed PR previews #202
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10M-scale spill run without eviction

2 participants