Repository navigation
perf(resolve): serve candidates from an in-memory corpus copy, reuse key auth's connection (#1429) - #1518
Conversation
325ca78 to
e7fd758
Compare
A resolver candidate (#1518, for #1429) has to be measured on er-dev before it reaches production. Only a merge or a manual dispatch could deploy it, and both ran the dev and prod jobs, so a dev-only release needed a by-hand blue/green outside CI. workflow_dispatch gains an `environment` input (both | dev | prod, default both). Each job skips when the input targets only the other environment. Merges are unchanged: they arrive through `images` and deploy both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* ci(deploy): let a manual deploy target dev or prod alone A resolver candidate (#1518, for #1429) has to be measured on er-dev before it reaches production. Only a merge or a manual dispatch could deploy it, and both ran the dev and prod jobs, so a dev-only release needed a by-hand blue/green outside CI. workflow_dispatch gains an `environment` input (both | dev | prod, default both). Each job skips when the input targets only the other environment. Merges are unchanged: they arrive through `images` and deploy both. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(deploy): regenerate the required-checks reference for the new job conditions The skills gate generates the deploy jobs' conditions into the ci-and-supply-chain reference. The dispatch `environment` input changed both, so the committed table was stale. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
e7fd758 to
93e43da
Compare
|
Heads-up from a parallel session (2026-12-03 ~01:00Z): the manual dev deploy of this branch at 00:45 (deploy run 47005705531, I have NOT rebuilt images for |
…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]>
93e43da to
be4bd8f
Compare
|
Resolved: this PR's merge ( |
Closes #1429
The dev-only release of this change met #1429's gate on er-dev before merge: in-cluster wall p95 116.7 / 120.6 ms at 779,861 records (server request p95 112 ms, prefilter p50 15 ms). The owner approved the production rollout afterwards. Measurement
What
__resolve_cache), and indexes the keys.ReuseKeyAuthlayer. The key extractor then keeps its connection and org row, and the handler stops reconnecting and re-reading the org by name. Other routes are unchanged.resolve request timings:auth_ms,lookup_ms,blocking_ms.resolve timingsgainssetup_ms,prefilter_keys_msandprefilter_lookup_ms.resolve corpus cached: build time, rows and memory, logged once per corpus change.Why
On er-dev at
a1dd29d5, standardize fell to 28 ms, but the prefilter only went from 138 to 123 ms p50, now 63% of the resolve. Pod: 1 CPU on an m6a.large, DuckDB on one thread, corpus on EFS (efs.csi.aws.comat/srv/er).Root cause: Parquet row-group decode, not I/O. Reading even one row decodes its whole row group. p3live's candidates sit in several of its ~15 data files, so every call decoded several files. The file cache served the bytes from memory but couldn't skip the decode.
The local benchmark had missed it because its corpus was one file. I wrote it in 15 files with the probe's matches in five, and the fetch went from about 2 to 21 ms. Rewriting the cross-file OR as per-file fetches with pushable filters changed nothing, which rules out filter pushdown.
The ~42 ms outside the resolve stages included two TLS Postgres connections per request, one in key auth and one in the handler, plus a duplicate org read.
Proof
a_warm_detached_resolve_reads_no_file_and_standardizes_each_field_oncenow also asserts that a warm call runs noread_parquet(from DuckDB's query log). It fails ona1dd29d5: "a warm resolve decoded Parquet".a_cached_attached_resolve_matches_the_lake_resolvecovers a persistent cache over an attached lake. It must equal the uncached resolve, and after a write that makes a new snapshot, the late record must be a candidate at once.pg_launch_proofruns against a local Postgres 16 over the key-auth reuse path, with a new unknown-dataset 404 case: pass.DEDUPE_E2E_DUCKLAKE=1 cargo test -p er-cli --test main resolve: 8 passed (the benchmark is ignored by design).make check: exit 0 (fmt, clippy, doc, entities-check, skills-check and the other gates, thencargo test --workspace: 1279 passed, 0 failed).Risk & rollback
git revert <merge-sha>.Post-merge ledger
Closed by: agent · session
Claude Code:cf299f4a-bafd-4f62-a459-2f495e05c5f2onMac· 2026-12-03T01:40: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:
f4c401d3. rust 47010872494, frontend 47010872442, infra 47010872302, devcontainer 47010872357 and images 47010872193 all success.imagesbuilt, or correctly never ran because nothing that goes intoan image changed: images 47010872193 built
er-api:f4c401d3(sha256:1e55c99e…). er-web was skipped, with no frontend change.deployconverged — proved by a line the running process emitted, notby the image digest and not by the workflow conclusion: deploy 47011447130 (
deploying f4c401d3…), dev and prod jobs success. Dev:ci/er-apiselects green, runningsha256:1e55c99e…. That process emitted this PR's new line,resolve corpus cached(build_ms 5760, 779,861 rows, 334.6 MiB), andresolve request timingson a real resolve. Prod's process-level proof is a separate item below.deploy,drift,kind's nightly leg) is green, or knowingly red for a reason that is notthis change: deploy green on dev and prod. This deploy also healed the two refused frontend deploys (c7e8bc3, f7ed273) that my dev-only candidate push caused; fix in fix(deploy): reuse the newest image built from the deployed commit's history #1552.
drifthas been red on schedule since at least Nov 29, before this change. Thekindnightly hasn't run since the merge; it doesn't exercise resolve.Donethrough the automation rather than byhand, and the issue closed: Resolve latency: ~2.1 s p50 at 520k records because the corpus is materialised per request #1429 closed by this merge (closing reference).
(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 measured results on Resolve latency: ~2.1 s p50 at 520k records because the corpus is materialised per request #1429; session memory notes on the deploy dispatch/reuse traps.Specific to this change
er-dev 55-call pass on p3live: server
requestp50/p95, theresolve timingsmedians (against prefilter 123 / 185 and resolve total 195 / 287), and the newprefilter_lookup_ms. On main's dev deploy (f4c401d3), in-cluster: wall p50/p95 110.9/123.3 and 105.8/122.7 ms over 2×55 calls, 779,861 records, snapshot 29533. Server request p50/p95 108/121.resolve timings: total 88/100, prefilter 16.1/19.8,prefilter_lookup_msp50 11.0, standardize 27.9. The candidate run before merge (dev-only,93e43da5) gave in-cluster p95 116.7/120.6. #1429The ~45 ms outside resolve: read
auth_ms,lookup_msandblocking_msfromresolve request timings, plussetup_msandload_ms. Ifauth_msis still the bulk, a pooled connection for key auth is the next lever. Request p50 108 vs resolve p50 88: the gap fell from ~45 to ~20 ms.auth_msp50/p95 12.6/15.8 is now most of it; lookup 0.8, load 5.1, setup 0.45. A pooled key-auth connection would save ~10 ms, and isn't needed for the gate.resolve corpus cachedon er-dev:build_ms,rowsandmemory, and the pod's memory after the pass (it was 729 MiB before).build_ms5760, rows 779,861, memory 334.6 MiB (dev-only candidate: 5541 ms, same size). After two warm passes the fresh green pod'ser-serveruses 395 MiB.Prod serving proof: blocked — this session has no read access to er-prod (the
er-mgmtSSO role has no EKS access entry there, ander-prod-adminuses the expireder-platformsession). The deploy-prod job succeeded andhttps://dupezero.com/api/healthzreturns{"ready":true,"upstream":"ok"}, but no line from prod's running process has been read. Whoever holds er-prod access: confirmapp/er-apiservessha256:1e55c99e….Context — plan, discoveries, measurements, files
Discoveries
web-api-blue). Over 119 warm calls the prefilter ranged 88–226 ms (p50 123). One cold call, so the session persisted.load_mswas about 4 ms.request − total − loadwas 42.6 / 50.7 ms (p50 / p95)./srv/eris EFS through the CSI driver with default mount options. DuckDB's spill directory is an emptyDir. The node is an m6a.large, spot. Single-core speed is about 2.4× below local, judging by standardize (28.3 against 11.7 ms).rowid in (…)was slower (40 ms): with candidates spread out, it scans most row groups. Only returning rows from the index lookups themselves avoids that.Extensionand the spec deriver. The OpenAPI deriver refusedExtension<…>as an unknown extractor. It now ignores it, likeStateandPrincipal: server-side state, never client input.Measurements
resolve_latency_at_scale, 779,728 records written in 15 files with the probe's matches in five (9 candidates), one thread. p50 / p95 in ms:a1dd29d5)The corpus copy holds 215.4 MiB with COMPRESS, against 531.5 MiB as a temp table, whose lookups are 3.1 ms instead of 6.0 ms. Build time is about 2.4 s.
Files
rust/crates/er-cli/src/lib.rs: the corpus copy, indexed fetch, prefilter timings andsetup_ms. Removes the file-cache settings and the per-call file fetch.rust/crates/er-cli/tests/lake_e2e.rs: the benchmark's 15-file shape, the no-read_parquetguard, and the attached-path test.rust/crates/er-server/src/lib.rs:ReuseKeyAuthandKeyAuth, the resolve handler's reuse, andresolve request timings.rust/crates/er-server/tests/pg_launch_proof.rs: the unknown-dataset 404 case.rust/crates/er-api-spec/src/operations/requests.rs: ignoreExtension..claude/skills/er-server-control-plane/references/handlers-and-state.md: the online-resolve reference.🤖 Generated with Claude Code