Skip to content

perf(resolve): a lake-free session for DuckDB-file catalogs, reading the data files directly (#1497) - #1500

Merged
athvin merged 2 commits into
mainfrom
perf/1429-metadata-cache
Nov 30, 2026
Merged

athvin merged 2 commits into
mainfrom
perf/1429-metadata-cache

Conversation

@athvin

@athvin athvin commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Closes #1497

Part of #1429. #1429 stays open until er-dev measures p95 under 300 ms.

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

What

  • Session::lake_data_files (dedupe-core): a relation's data files, only when they alone reproduce it: no delete files, and the file rows equal the table's, so nothing is inlined in the catalog.
  • er_cli::detach_corpus and ResolveCache::set_detached: resolve reads the standardized corpus and the membership as read_parquet over those files. The prefilter key cache is keyed by a change stamp, and the snapshot is the one the files were listed at.
  • er-server: a DuckDB-file catalog dataset keeps an in-memory session per env that holds no lake handle.
    • The stamp is the mtime and size of the catalog file and its .wal.
    • The lake is opened only when the stamp changes, to re-list the files, and then closed.
    • Each call prefilters on the cached keys and reads only the candidates' rows.
    • A relation the files can't reproduce falls back to resolving through the lake.

Why

On er-dev, p3live's ER_LAKE_CATALOG is a DuckDB file on EFS, so #1482's Postgres-only session never applied: 61/61 calls logged persistent=false.

Per call (from e1b7ef0d's resolve timings):

  • about 700 ms outside the phases: the lake attach;
  • prefilter about 390 ms: a scan of the 259 MB, 15-file corpus;
  • standardize about 425 ms;
  • p50 1674 / p95 2112 ms in total.

A file catalog can't be held between requests: its handle would lock out the runner pods' writes.

Proof

  • a_detached_resolve_matches_the_lake_resolve (base_10): the detached resolve equals the lake resolve (decision, candidates, probabilities, entity ids, snapshot), twice over the cached session.
  • pg_launch_proof, whose lake is a local DuckDB file, passes on the detached path, including a run that writes the lake between resolves, so the writer isn't locked out.
  • er-cli resolve tests (8) pass, and the freeform_sql gate passes.
  • make check: exit 0.

Risk & rollback

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

  • er-dev resolve latency on p3live after deploy, 55 calls, with persistent=true in the resolve timings events:

🤖 Generated with Claude Code

bmoore813 and others added 2 commits November 30, 2026 03:32
…the data files directly (#1497)

er-dev's p3live keeps its catalog as a DuckDB file on EFS, so #1482's cached
session never applied: every call attached the lake (~700 ms) and scanned the
259 MB corpus (~390 ms). A DuckDB-file catalog cannot be held between requests;
the handle would lock out the runner pods' writes.

- er_cli::detach_corpus lists, from an attached lake, the standardized
  corpus's and the membership's data files as read_parquet sources, plus the
  snapshot. It returns None, and the caller resolves through the lake, when a
  relation has delete files, has rows inlined in the catalog (the files' count
  differs from the table's), or is missing. ResolveCache::set_detached makes
  resolve_record_cached read those sources: corpus, prefilter key cache keyed
  by the change stamp, membership join, and snapshot.
- er-server: a file-catalog dataset keeps an in-memory session and cache per
  env. The stamp is the mtime and size of the catalog file and its .wal. The
  lake is opened only when the stamp changes, to re-list the files, and then
  closed. Each call runs without a lake handle and reads only the candidates'
  rows. A failed resolve drops the session.

a_detached_resolve_matches_the_lake_resolve: on base_10, a detached resolve
equals the lake resolve (decision, candidates, probabilities, entity ids,
snapshot), twice over the cached session. pg_launch_proof, whose lake is a
local DuckDB file, passes on the detached path, including the run that writes
the lake between resolves. er-cli resolve tests pass (8).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The freeform_sql gate allows no free-form lake reads outside dedupe-core. The
catalog file listing and the row-count check behind detach_corpus are DuckLake
mechanics, like lake_table_exists, so they move to Session::lake_data_files.
er-cli only builds the read_parquet source from its answer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit bbf4e4a into main Nov 30, 2026
44 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 30, 2026 08:42 — with GitHub Actions Inactive
athvin added a commit that referenced this pull request Nov 30, 2026
… cache a refused detach (#1502) (#1503)

On er-dev bbf4e4a the lake-free path never ran (persistent=false on 61/61),
and wall time rose about 500 ms. p3live's entity_membership has delete files or
inlined rows, so detach_corpus refused. Nothing cached the refusal, so every
call opened the lake twice: the failed detach, then the fallback.

- The serving in-memory session refreshes itself. er_cli::attach_lake attaches
  the catalog, detach_corpus lists the corpus's data files and copies
  entity_membership into the session temp table __resolve_membership through
  the catalog (Session::copy_lake_table), so deletes and inlined rows apply
  exactly. Then Session::detach_lake releases the lock, whatever the refresh
  did. Only the corpus must be plain data files.
- A refusal returns its reason. The server logs it once and records it per
  change stamp (ResolveCache::refuse), so a fallback dataset opens the lake
  once per call, as before #1500, and no detach is retried until the catalog
  changes.

a_detached_resolve_matches_the_lake_resolve now refreshes the serving session
itself (attach, detach_corpus, detach_lake) after the lake session releases
the file catalog, and still equals the lake resolve. pg_launch_proof (local
DuckDB-file lake, with a run writing it between resolves) passes. Resolve tests
(8) and the freeform_sql gate pass.

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 — 34b5adb0 Deployed Nov 30, 2026 by athvin via remove closed PR previews #195
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.

Resolve over a DuckDB-file catalog attaches the lake and scans the whole corpus on every call (#1429 follow-up)

2 participants