Skip to content

perf(ingest): a delivery lands in ONE staged write instead of a 500-row INSERT per chunk (#1453) - #1475

Merged
athvin merged 1 commit into
mainfrom
perf/1453-ingest-parallel
Nov 30, 2026
Merged

athvin merged 1 commit into
mainfrom
perf/1453-ingest-parallel

Conversation

@athvin

@athvin athvin commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Closes #1453

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

What

A delivery's rows now stream through a DuckDB appender into a session temp table. One declared statement, raw_record.create.append_from_src, then writes them into raw_records in CSV order. This replaces a 500-row bound-parameter INSERT per chunk.

Why

At 10M records the old path was 20,000 statements and 20,000 Parquet files. #558's er-dev run spent 79 minutes in single-core ingest (17:07:48 → 18:26:52Z), the longest stage of the run.

Proof

Release build, 1M rows of the #558 corpus: 22.1 s (15.0 s CSV parse and row prep, 7.0 s the single write), one Parquet file. Debug build at 100k: 27.3 s and 200 files before, 14.4 s and 1 file after. The large-delivery test now asserts CSV order. The rollback, golden and receipt tests pass unchanged. make check exit 0.

Risk & rollback

The delivery stays in its one lake transaction, so a failed write lands nothing and a retry is clean (tested). Rows aren't buffered in memory. Rollback: git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on Mac · 2026-11-30T05:47:40Z

Specific to this change

  • the live 10M ingest is faster — 10M-scale spill run without eviction #558 job 01a22b06… on er-dev, class L, 10,011,103 records: ingest 7m51s (05:57:47 → 06:05:38Z) on this build, against 79m04s on the per-chunk INSERT build (17:07:48 → 18:26:52Z on 2026-11-29).
Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

🤖 Generated with Claude Code

…ow INSERT per chunk (#1453)

land_base_delivery issued one bound-parameter INSERT of 500 rows per
chunk. At 10M records that was 20,000 statements and 20,000 Parquet
files, and on er-dev the ingest ran single-core for over an hour (two
tries ran 67 minutes each before #1449 killed them).

Rows now stream into a session temp table through a DuckDB appender,
and one declared statement (raw_record.create.append_from_src) writes
them into lake.main.raw_records in CSV order (ORDER BY seq). The
delivery stays inside its one lake transaction, so a failed write still
lands nothing and a retry is clean. Rows aren't buffered in memory, so
10M rows never sit in a Vec. This is the #1409 pattern, as used for
events.

Measured (release build, 1M rows of the #558 corpus): 22.1 s, of which
15.0 s is CSV parse and row prep and 7.0 s the single write, with one
Parquet file. In a debug build at 100k: 27.3 s and 200 files before,
14.4 s and 1 file after.

The large-delivery test now also asserts CSV order. The rollback and
golden tests pass unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit faf79d1 into main Nov 30, 2026
44 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 30, 2026 05:19 — with GitHub Actions Inactive
athvin added a commit that referenced this pull request Nov 30, 2026
… in memory at 10M (#1494) (#1496)

#1475 staged a delivery and wrote it in one INSERT … SELECT, so one
Parquet file. #558's 10M run then failed in standardize: Out of Memory,
7.4/7.4 GiB at class L, three minutes in. With the old layout (500-row
files) standardize had passed at 10M in 7.4 minutes.

Bisected locally at 2M rows with a 1.5 GB limit:
- one file OOMs at 4 and 12 threads and passes at 1 and 2, so the cost
  is per-thread scan state;
- small Parquet row groups inside one file (2048, 4096, 16384) still
  OOM, as do 2,000- and 20,000-row files;
- disabling parquet prefetching or the metadata cache doesn't help;
- 500-row files pass at 12 threads, twice;
- moving the current-version window before the transforms didn't help,
  so it isn't part of this change.

The staged appender stays. append_from_src now takes a seq range, and
landing writes the staged rows in RAW_FILE_ROWS (500) slices, one short
statement each. The old path's cost was 5,500 bound parameters per
statement, not the count. Measured (debug build, 2M rows): ingest
111.7 s against 106 s for one file, 4,000 files, and standardize passes
at 1.5 GB / 12 threads in 165.5 s.

The large-delivery test (1,201 rows, three slices) still asserts CSV
order. The rollback and golden tests pass.

Co-authored-by: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
athvin added a commit that referenced this pull request Nov 30, 2026
…ndardize needs more than 8GB of DuckDB (#558) (#1501)

#558's 10M run on er-dev, with a realistic-cardinality corpus, failed
standardize with Out of Memory (7.4/7.4 GiB) at class L's 14Gi / 8GB:
- on #1475's single-file layout, after 3 minutes;
- on #1496's 500-row files, after 4.5 minutes, at 13.2 of 14 GiB.
The old layout's earlier pass at 10M was on a low-cardinality corpus.

Every runner-l shape has at least 32 GiB (c5ad, c6id or c8id.4xlarge;
m6id has 64), and L used 14 of it. L is now 26Gi with DuckDB at 18GB,
which keeps DuckDB strictly below the container (the D-SIZING
invariant) and leaves room for the node's daemonsets. That means one L
pod per node. The dev namespace already admits at most two L pods,
since ephemeral storage refuses a third: 2 x 26Gi + app = 57Gi of the
80Gi quota.

helm template renders ER_DUCKDB_MEMORY_LIMIT=18GB with 26Gi requests
and limits. infrastructure.md §6.5, batch-orchestration-design and the
quota comment are updated.

Co-authored-by: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
marketing-preview — 69945c60 Deployed Nov 30, 2026 by athvin via remove closed PR previews #179
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.

perf(ingest): a 10M-record ingest runs on one core for over an hour — class L's 16 vCPUs buy it nothing

2 participants