Skip to content

fix(standardize): build int_std_records in key-hash buckets, so a 10M corpus fits in memory (#558) - #1504

Merged
athvin merged 1 commit into
mainfrom
fix/558-standardize-buckets
Nov 30, 2026
Merged

athvin merged 1 commit into
mainfrom
fix/558-standardize-buckets

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

int_std_records (and acct_int_std_records) is built in buckets of hash(source_system, source_record_id): a CREATE TABLE AS for bucket 0, then an INSERT per further bucket. Bucket count is ceil(rows / 1M), overridable with ER_STD_ROWS_PER_BUCKET. One bucket is exactly the old SQL.

Why

The 10M run failed standardize with Out of Memory at 8GB, and again at 18GB after #1501 (16.7/16.7 GiB). The working set grows with the corpus and doesn't spill. The current-version window partitions by the bucket key, so every version of a record shares a bucket and the union of the buckets is the single statement's result.

Proof

Locally, 2M rows at a 1.5 GB limit and 12 threads with 500k buckets: standardize passes in 278 s with all 2,000,000 rows. std_hashes builds base_10 in 3-row buckets and requires the same table in both directions of EXCEPT ALL. make check exit 0. The live 10M rerun on this build is the ledger's proof.

Risk & rollback

Up to 1M rows: identical SQL. Above that: N statements in one stage. 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

… corpus fits in memory (#558)

#558's 10M run kept failing standardize with Out of Memory: at 8GB
(7.4/7.4 GiB), and after #1501 raised class L, at 18GB (16.7/16.7 GiB).
Its working set grows with the corpus and DuckDB doesn't spill enough of
the projection plus the current-version window. Locally, 2M rows need
more than 1.5GB.

The corpus is now standardized in buckets of hash(source_system,
source_record_id): a CREATE TABLE AS for bucket 0, then an INSERT per
further bucket. The window partitions by exactly that key, so every
version of a record shares a bucket, and the union of the buckets is the
single statement's result. Bucket count is ceil(rows / 1M);
ER_STD_ROWS_PER_BUCKET overrides it. One bucket (any corpus up to 1M) is
the same SQL as before. Both the person and account builders use it.

Measured locally (2M rows, 1.5 GB limit, 12 threads, 500k-row buckets):
standardize passes in 278 s with all 2,000,000 rows. std_hashes now also
builds base_10 in 3-row buckets and requires the same table, both
directions of EXCEPT ALL. build_int_std_records_with takes the bucket
size, so the test doesn't touch the process env.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit 8211cb0 into main Nov 30, 2026
44 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 30, 2026 10:57 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — 0270a519 Deployed Nov 30, 2026 by athvin via remove closed PR previews #198
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