Skip to content

fix(resolve): cache sessions over ducklake:postgres: catalogs, and one scan for one-off calls (#1429) - #1482

Merged
athvin merged 1 commit into
mainfrom
perf/1429-cacheable-catalog
Nov 30, 2026
Merged

athvin merged 1 commit into
mainfrom
perf/1429-cacheable-catalog

Conversation

@athvin

@athvin athvin commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Closes #1429

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

What

Why

#1476 made no difference on er-dev, and its p95 got worse. Measured by the project-2 session on 5f1e3bb9 against p3live, 55 calls each pass:

Pass p50 p95 max
1 2211 ms 3888 ms 17043 ms
2 2188 ms 5500 ms 8380 ms
3 2273 ms 7778 ms 11065 ms

The web-api pod sat at 825m of its 1-CPU limit.

Cause: provisioning writes the catalog as ducklake:postgres:…, and the cacheability check accepted only postgres:. So er-dev never kept a session, and every call took the one-off path. In #1476 that path scanned the S3 corpus twice: once for the key table, once for the candidates.

Proof

  • only_a_postgres_catalog_caches_resolve_sessions covers ducklake:postgres:.
  • er-cli resolve (7) and acct_ (12) pass.
  • resolve_latency_at_scale uses the persistent cache, and its answers still equal the uncached call's.
  • make check: exit 0.
  • Acceptance: er-dev p95 under 300 ms at p3live. It's measured after deploy and goes in the ledger below.

Risk & rollback

er-dev now actually keeps a resolve session per dataset, as #1476 intended: a narrow key table (tens of MB at 520k) plus the TF tables, at most 32 envs. Rollback is 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

  • er-dev resolve latency at p3live (about 520k), 55 calls after 5 warm-ups: p50/p95/max against the 300 ms p95 target:

🤖 Generated with Claude Code

…e scan for one-off calls (#1429)

#1476 made no difference on er-dev, and its p95 got worse (p50 about 2.2 s, p95
3.9 to 7.8 s). Provisioning writes ER_LAKE_CATALOG as ducklake:postgres:..., and
resolve_session_cacheable accepted only postgres:, so er-dev never kept a
session. Every call then took the one-off path, which in #1476 scanned the S3
corpus twice: once to build the key table and again to fetch candidates.

- resolve_session_cacheable accepts ducklake:postgres: as well as postgres:. A
  unit test pins the provisioned form.
- ResolveCache::persistent() marks a cache that outlives the call; the server
  uses it. A one-off cache (resolve_record) filters the lake corpus directly in
  one scan, as before #1476's key table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit e18d60d into main Nov 30, 2026
43 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 30, 2026 06:29 — with GitHub Actions Inactive
athvin added a commit that referenced this pull request Nov 30, 2026
…each resolve's time goes (#1495) (#1493)

After #1482 er-dev resolve was p50 1660 / p95 2015 ms (pod at its 1-CPU limit).
Single-threaded, as that pod runs, the local 520k benchmark is p50 260 /
p95 282 ms. So er-dev's extra ~1.4 s is something only production has. The
prime suspect is the dictionaries: every call dropped and re-seeded the nickname
lexicon and ignore-words tables, which are tiny in the fixtures and large in
production.

- A persistent ResolveCache seeds the dictionaries once per content hash.
- er_cli logs one 'resolve timings' event per call (seed, standardize,
  prefilter, prepare, predict, select, total, and the corpus candidates kept).
  er-server logs 'resolve inputs loaded' with the model, config and dictionary
  load time and the dictionary sizes. The next er-dev pass shows where any time
  remains.
- resolve_latency_at_scale times single-threaded by default
  (ER_RESOLVE_THREADS), matching the pod.

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
…the data files directly (#1497) (#1500)

* perf(resolve): a lake-free session for DuckDB-file catalogs, reading 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]>

* refactor(lake): list a relation's data files in the engine core (#1497)

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]>

---------

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 — 2b4c83b9 Deployed Nov 30, 2026 by athvin via remove closed PR previews #185
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 latency: ~2.1 s p50 at 520k records because the corpus is materialised per request

2 participants