Repository navigation
perf(resolve): standardize the probe staged, serve warm calls from the file cache, drop per-call objects (#1429) - #1515
Merged
Conversation
…e file cache, drop per-call objects (#1429) On er-dev, p3live's 411 ms server resolve spent 227 ms standardizing its one probe record and 138 ms in the prefilter. p3live is served by the detached path, so neither stage touched a catalog. Standardize was CPU. The inline normalizer text extracts one crm record's 11 payload fields 83 times (`phone` 38 times). DuckDB plans and evaluates every copy, and re-plans a prepared statement that reads a table on every EXECUTE. `er_std::sql` generators now route repeated values through a `Share`. `Inline` keeps the corpus SQL byte-identical. `Staged`, used only for the probe, computes each value once in a lower projection. Locally at 780k records on one thread, standardize drops from 85.5 to 11.7 ms p50. The prefilter's only file access was the per-call read of the hit Parquet files on EFS. `detach_corpus` turns on DuckDB's external file cache for local files, with local revalidation off because DuckLake data files are write-once. It also turns on the Parquet metadata cache and pins the prefetch gap, whose cost model reopened the file. The detached corpus view is registered once per file listing. Each call now drops the views and tables it created; a kept session used to grow by about 392 KB per call. `predict_between` drops its hierarchy closure. The local end-to-end call drops from 141/144 ms to 64/66 ms (p50/p95). a_warm_detached_resolve_reads_no_file_and_standardizes_each_field_once reads DuckDB's query and file-system logs to pin all three changes, and fails on the old code. staged_standardization_equals_inline holds the two renderings to the same rows over every er-std golden input. Refs #1429 Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
temporarily deployed
to
marketing-preview
December 2, 2026 06:25 — with
GitHub Actions
Inactive
athvin
pushed a commit
that referenced
this pull request
Dec 3, 2026
…key auth's connection (#1429) On er-dev, #1515 brought standardize to 28 ms but the prefilter only fell from 138 to 123 ms. Serving the Parquet bytes from the file cache removed the EFS reads, not the decode. Reading even one row decodes its whole row group, and a probe's candidates span several of p3live's ~15 files. Reproduced locally by writing the benchmark corpus in 15 files with the probe's matches planted in five of them: the fetch went from about 2 to 21 ms. Rewriting the cross-file OR as one per-file fetch with pushable filters changed nothing. On each corpus change the session now copies the whole corpus, with its precomputed blocking keys, into a compressed in-memory database, and indexes the keys. Each indexed lookup returns its candidates' rows directly; filtering the copy by row id would scan every row group holding one. A warm call reads no Parquet, on either path. At 780k records the copy holds 215 MiB, against 531 MiB as a temp table, and takes about 2.4 s to build once. The file-cache settings from #1515 are removed, because they would only hold a second copy. On the er-dev-shaped corpus, local, one thread: prefilter 25.2 -> 8.1 ms p50, end to end 87/90 -> 69/73 ms p50/p95. The handler spent ~42 ms outside the resolve stages, and opened two TLS Postgres connections per request. The resolve route now opts in (`ReuseKeyAuth`) to keeping the key extractor's connection and org row, so the handler neither reconnects nor re-reads the org. New log fields: `resolve request timings` (auth, lookup, blocking), `setup_ms` and the prefilter's keys/lookup split on `resolve timings`, and `resolve corpus cached` (build time, rows, memory), so the next er-dev pass accounts for every millisecond. a_warm_detached_resolve_reads_no_file_and_standardizes_each_field_once now asserts a warm call runs no `read_parquet`, and fails on the previous code. a_cached_attached_resolve_matches_the_lake_resolve covers the attached path and its rebuild on a new snapshot. Refs #1429 Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
pushed a commit
that referenced
this pull request
Dec 3, 2026
…key auth's connection (#1429) On er-dev, #1515 brought standardize to 28 ms but the prefilter only fell from 138 to 123 ms. Serving the Parquet bytes from the file cache removed the EFS reads, not the decode. Reading even one row decodes its whole row group, and a probe's candidates span several of p3live's ~15 files. Reproduced locally by writing the benchmark corpus in 15 files with the probe's matches planted in five of them: the fetch went from about 2 to 21 ms. Rewriting the cross-file OR as one per-file fetch with pushable filters changed nothing. On each corpus change the session now copies the whole corpus, with its precomputed blocking keys, into a compressed in-memory database, and indexes the keys. Each indexed lookup returns its candidates' rows directly; filtering the copy by row id would scan every row group holding one. A warm call reads no Parquet, on either path. At 780k records the copy holds 215 MiB, against 531 MiB as a temp table, and takes about 2.4 s to build once. The file-cache settings from #1515 are removed, because they would only hold a second copy. On the er-dev-shaped corpus, local, one thread: prefilter 25.2 -> 8.1 ms p50, end to end 87/90 -> 69/73 ms p50/p95. The handler spent ~42 ms outside the resolve stages, and opened two TLS Postgres connections per request. The resolve route now opts in (`ReuseKeyAuth`) to keeping the key extractor's connection and org row, so the handler neither reconnects nor re-reads the org. New log fields: `resolve request timings` (auth, lookup, blocking), `setup_ms` and the prefilter's keys/lookup split on `resolve timings`, and `resolve corpus cached` (build time, rows, memory), so the next er-dev pass accounts for every millisecond. a_warm_detached_resolve_reads_no_file_and_standardizes_each_field_once now asserts a warm call runs no `read_parquet`, and fails on the previous code. a_cached_attached_resolve_matches_the_lake_resolve covers the attached path and its rebuild on a new snapshot. Refs #1429 Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
pushed a commit
that referenced
this pull request
Dec 3, 2026
…key auth's connection (#1429) On er-dev, #1515 brought standardize to 28 ms but the prefilter only fell from 138 to 123 ms. Serving the Parquet bytes from the file cache removed the EFS reads, not the decode. Reading even one row decodes its whole row group, and a probe's candidates span several of p3live's ~15 files. Reproduced locally by writing the benchmark corpus in 15 files with the probe's matches planted in five of them: the fetch went from about 2 to 21 ms. Rewriting the cross-file OR as one per-file fetch with pushable filters changed nothing. On each corpus change the session now copies the whole corpus, with its precomputed blocking keys, into a compressed in-memory database, and indexes the keys. Each indexed lookup returns its candidates' rows directly; filtering the copy by row id would scan every row group holding one. A warm call reads no Parquet, on either path. At 780k records the copy holds 215 MiB, against 531 MiB as a temp table, and takes about 2.4 s to build once. The file-cache settings from #1515 are removed, because they would only hold a second copy. On the er-dev-shaped corpus, local, one thread: prefilter 25.2 -> 8.1 ms p50, end to end 87/90 -> 69/73 ms p50/p95. The handler spent ~42 ms outside the resolve stages, and opened two TLS Postgres connections per request. The resolve route now opts in (`ReuseKeyAuth`) to keeping the key extractor's connection and org row, so the handler neither reconnects nor re-reads the org. New log fields: `resolve request timings` (auth, lookup, blocking), `setup_ms` and the prefilter's keys/lookup split on `resolve timings`, and `resolve corpus cached` (build time, rows, memory), so the next er-dev pass accounts for every millisecond. a_warm_detached_resolve_reads_no_file_and_standardizes_each_field_once now asserts a warm call runs no `read_parquet`, and fails on the previous code. a_cached_attached_resolve_matches_the_lake_resolve covers the attached path and its rebuild on a new snapshot. Refs #1429 Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
added a commit
that referenced
this pull request
Dec 3, 2026
…key auth's connection (#1429) (#1518) On er-dev, #1515 brought standardize to 28 ms but the prefilter only fell from 138 to 123 ms. Serving the Parquet bytes from the file cache removed the EFS reads, not the decode. Reading even one row decodes its whole row group, and a probe's candidates span several of p3live's ~15 files. Reproduced locally by writing the benchmark corpus in 15 files with the probe's matches planted in five of them: the fetch went from about 2 to 21 ms. Rewriting the cross-file OR as one per-file fetch with pushable filters changed nothing. On each corpus change the session now copies the whole corpus, with its precomputed blocking keys, into a compressed in-memory database, and indexes the keys. Each indexed lookup returns its candidates' rows directly; filtering the copy by row id would scan every row group holding one. A warm call reads no Parquet, on either path. At 780k records the copy holds 215 MiB, against 531 MiB as a temp table, and takes about 2.4 s to build once. The file-cache settings from #1515 are removed, because they would only hold a second copy. On the er-dev-shaped corpus, local, one thread: prefilter 25.2 -> 8.1 ms p50, end to end 87/90 -> 69/73 ms p50/p95. The handler spent ~42 ms outside the resolve stages, and opened two TLS Postgres connections per request. The resolve route now opts in (`ReuseKeyAuth`) to keeping the key extractor's connection and org row, so the handler neither reconnects nor re-reads the org. New log fields: `resolve request timings` (auth, lookup, blocking), `setup_ms` and the prefilter's keys/lookup split on `resolve timings`, and `resolve corpus cached` (build time, rows, memory), so the next er-dev pass accounts for every millisecond. a_warm_detached_resolve_reads_no_file_and_standardizes_each_field_once now asserts a warm call runs no `read_parquet`, and fails on the previous code. a_cached_attached_resolve_matches_the_lake_resolve covers the attached path and its rebuild on a new snapshot. Refs #1429 Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1429
This change does not close #1429. That issue closes only after the 55-call er-dev measurement meets the wall p95 < 300 ms gate. It carries the
no-ticketlabel for that reason.What
int_std_records_sql_staged/acct_int_std_records_sql_staged. These use the corpus's owner_std::sqlnormalizers, routed through a newSharehook.Stagedcomputes each repeated value once, as a column of a lower projection.Inlinereturns the original text, so the corpus standardization SQL is byte-identical: I verified this by diffing the person, person-with-rules and account renderings before and after.detach_corpusturns on DuckDB's external file cache for local files (cache_local_files,VALIDATE_REMOTE) and the Parquet metadata cache.parquet_prefetch_column_gap. Otherwise the prefetch cost model opens the file to estimate throughput.predict_betweenalso drops its hierarchy closure.Why
The 2026-12-02 er-dev pass on
f3cb5edehad server p50 411 ms:standardize_ms227 andprefilter_ms138. p3live is served by the detached path: an in-memory session with no catalog attached during a call. So neither stage made a catalog round trip.phonealone is extracted 38 times, becausenull_semanticsand the phone, name and address generators repeat their operands. DuckDB plans and evaluates every copy. Preparing the statement would not help: DuckDB 2.0.1 marks any prepared statement that reads a tablealways_require_rebind(optimizer.cpp:588), so it is re-planned on everyEXECUTE. I measuredEXECUTEat about 80 ms versus 45 ms forPREPARE.read_parquetof the hit files, which on er-dev is EFS.Proof
a_warm_detached_resolve_reads_no_file_and_standardizes_each_field_once(er-cli lake e2e). It reads DuckDB's ownQueryLogandFileSystemlogs over one warm call, on er-dev's detached path. It asserts no OPEN or READ of a corpus file, each payload field extracted once, no growth in temp objects, and the same answer as the lake resolve.HEAD's resolve it fails on the file I/O assertion: one warm call opened the corpus file 3 times and read it twice.first_name was planned 8 times.temp objects 69 != 64.staged_standardization_equals_inlineandstaged_account_standardization_equals_inline(er-standardize). They buildint_std_recordsboth ways over every input in er-std's normalizer goldens, placed into every mapped field of every source. The person configs include plus-stripping, placeholders, a cleanse rule and a GB region. The check isexcept allin both directions. A mutation that conflatesStagedentries fails both tests.DEDUPE_E2E_DUCKLAKE=1 cargo test -p er-cli: 74 passed, 1 ignored (the benchmark).cargo test -p er-standardize -p er-std: pass.pg_launch_proofagainst a local Postgres 16 (DuckLake tier, DuckDB-file lake, i.e. the detached path): pass.make check: exit 0 (fmt, clippy, doc, entities-check, skills-check and the other gates, thencargo test --workspace: 1278 passed, 0 failed).Risk & rollback
sharecall is still correct, just slower, and the equivalence test covers new goldens automatically.git revert <merge-sha>.Post-merge ledger
Closed by: agent · session
Claude Code:cf299f4a-bafd-4f62-a459-2f495e05c5f2onMac· 2026-12-02T06:42:00Zmainis green with this change on it — the merge SHA, and the runthat proves it. A later head SHA with this commit as an ancestor counts;
a cancelled run with zero jobs does not:
a1dd29d5. rust 46824529215, frontend 46824528808, infra 46824528947, devcontainer 46824528770 and images 46824528845 all success.imagesbuilt, or correctly never ran because nothing that goes intoan image changed: images 46824528845 success on
a1dd29d5.deployconverged — proved by a line the running process emitted, notby the image digest and not by the workflow conclusion: deploy 46825081522 logged
deploying a1dd29d512d9895c3622e590570f2f46fbdef74c, and both the dev and prod jobs succeeded.ci/er-apiswitched to blue (er-api@sha256:6edf36df…). That process'sresolve timingslines showstandardize_msp50 28.3 ms on 55 calls, against 227 ms before. That is this PR's staged standardization running.deploy,drift,kind's nightly leg) is green, or knowingly red for a reason that is notthis change: deploy green, dev and prod.
driftis knowingly red for reasons that predate this change: it has failed on every scheduled run since at least Nov 29 (46231663846, 46363578852, 46587395674, and 46821594846 on 71a493d, before this merge). blocked —kind's nightly leg hasn't run since the merge; it runs tonight.Donethrough the automation rather than byhand, and the issue closed: deferred — Resolve latency: ~2.1 s p50 at 520k records because the corpus is materialised per request #1429 stays open, correctly. Its live gate is still missed: wall p95 515 / 459 ms over two 55-call passes, server request p95 344 ms. The next lever is the prefilter (below).
(a skill, a reference, memory) — or nothing new was learned: the online-resolve section of
er-server-control-plane/references/handlers-and-state.md(this PR). The live result, including that the prefilter did not drop, is on Resolve latency: ~2.1 s p50 at 520k records because the corpus is materialised per request #1429.Specific to this change
resolve timingsmedians, againststandardize_ms227 /prefilter_ms138 / server p50 411 ms. Theprefilter_msdrop is the EFS claim this PR could not measure locally. Done, 2026-12-02 06:36 and 06:38 UTC: two passes of 5 warm-ups + 55 calls on p3live/default (779,861 records, snapshot 29533, a temporary viewer key since revoked). Wall p50/p95 416/515 ms, then 413/459 ms, through a port-forward whose/healthzfloor is 168 ms. Serverresolve timingsp50: standardize 28.3 (was 227), prefilter 122.7 (was 138; p95 185), prepare 5.4, predict 23.6, select 12.3, total 195.4 (was 411; p95 287, then 227 on pass 2). Server request duration p50/p95 240/344 ms. The EFS file-cache claim did not hold: the prefilter fell only 11%.er-serverinweb-api-blue-9c6fdc855-jcp4fwent from 721 MiB to 729 MiB across the second 60-call pass, which is flat; the 06:36 pass had already warmed it.Context — plan, discoveries, measurements, files
Discoveries
ducklake:postgres:and served attached. p3live is not. Before fix(resolve): copy the membership through the catalog on refresh, and cache a refused detach (#1502) #1503 it loggedpersistent=falseon 61/61 calls, which only the non-Postgres branch emits. It now logspersistent=true, which for a file catalog means the detached path. During a call that session has no lake attached, so there were no catalog round trips to remove.CASE. DuckDB's common-subexpression pass skips short-circuitedCASEbranches. The analyser already needed a 16 MB stack to plan the inline standardization.cache_local_filesis set ("the OS page cache already serves repeated reads"), which EFS defeats.CachingFileHandle::TryGetNetworkThroughputopens the file even when every byte is cached, which is why the prefetch gap is pinned.Measurements
resolve_latency_at_scale(ignored er-cli test), 779,999 records, one thread, 20 timed calls after 5 warm-ups. Per-phase p50 / p95 in ms, from theresolve timingsphases:f3cb5ede)Standardization statement alone, same probe: plan only (
EXPLAIN) 58 → 12 ms, CTAS 84 → 11 ms. The staged SQL is 7.3 KB, against 20.3 KB inline.Projection for er-dev (not measured): scaling standardize by the local ratio gives 227 → about 31 ms. If the prefilter loses its EFS reads it should approach its in-memory cost. That puts the server near or under 100 ms against the 150 ms headroom target. The remaining big phase is predict (23 ms on er-dev, 38 locally).
Files
rust/crates/er-std/src/sql.rs:Share,InlineandStaged, plus the_invariant of each generator.rust/crates/er-standardize/src/lib.rs:Rendering, the staged SQL and builders, andtests/staged.rs.rust/crates/er-cli/src/lib.rs: staged probe,CallObjectscleanup, cached corpus view, and file-cache settings indetach_corpus. The guard is intests/lake_e2e.rs.rust/crates/dedupe-core/src/incremental.rs:predict_betweendropsancestors.rust/crates/er-sql-check/src/stage.rs: plans the staged renderings..claude/skills/er-server-control-plane/references/handlers-and-state.md: the online-resolve reference.🤖 Generated with Claude Code