Skip to content

Resolve latency: ~2.1 s p50 at 520k records because the corpus is materialised per request #1429

Done

Description

@athvin

Measured by #1365 on er-dev (2026-11-29). Org p3live, about 520k standardized person records, the web-api pod's default resources. 55 POST …/resolve calls after 5 warm-ups:

p50 p95 max
2092 ms 2199 ms 2309 ms

All 60 returned 200. Each scores one record, so the cost is per-request setup, not scoring. resolve_record registers the whole standardized corpus and runs materialize_concat over it on every call, then blocks the probe against all of it.

Done when a resolve at this corpus size has p95 under 300 ms, for example by blocking the probe against the corpus with its blocking-rule keys pushed into the lake scan instead of materialising the corpus per request. Record the before/after in the er-server-control-plane reference.

Activity

  1. athvin commented on Nov 29, 2026

    @athvin
    OwnerAuthor

    Claimed by a Claude Code session (coordinated with the project-2 session, which is staying off it). This will follow the duck-fleet #273 work.

  2. athvin commented on Nov 30, 2026

    @athvin
    OwnerAuthor

    Reopening: #1482's merge closed this, but er-dev hasn't met the target (p95 under 300 ms at about 520k).

    er-dev on p3live so far, 55 calls per pass:

    Build p50 p95
    #1365 baseline 2092 ms 2199 ms
    after #1476 (5f1e3bb9) about 2200 ms 3888–7778 ms
    after #1482 (e18d60dc) 1660 ms 2015 ms

    #1476 never kept a session, because the catalog check missed ducklake:postgres:. #1482 fixed that, and the tail spikes are gone, but each call still costs about 1.6 s of CPU on the 1-core pod. Single-threaded, the local 520k benchmark runs 260/282 ms, so the remainder is production-only.

    #1493 (closing #1495) seeds the dictionaries once per session and logs a per-phase resolve timings event. The next er-dev pass will say where the time goes.

  3. reopened this on Nov 30, 2026
  4. athvin commented on Nov 30, 2026

    @athvin
    OwnerAuthor

    Progress on er-dev (p3live/default, about 520k records), measured by the project-2 session: 55 calls after 5 warm-ups per pass, through a port-forward to the 1-CPU web-api pod.

    Build wall p50 wall p95 server total_ms (median) prefilter standardize
    #1365 baseline 2092 2199 n/a n/a n/a
    #1482 e18d60dc 1660 2015 n/a n/a n/a
    #1493 e1b7ef0d (persistent=false) 1674 2112 981 388 425
    #1503 28b33aa0 (lake-free session) 1164 1447 945 632 249
    #1506 51e3671e (precomputed keys, candidate rows only) 817 972 604 320 227

    All times are ms. About 215 ms of each wall time sits outside the server's total_ms (HTTP, auth, the measurement's port-forward), so a 300 ms wall p95 needs the server under about 85 ms on one CPU. Next: read candidates only from the files that hold them (EFS reads), then the one-row standardization's planning cost.

  5. athvin commented on Dec 1, 2026

    @athvin
    OwnerAuthor

    The indexed candidate from #1512 built and its single-thread local benchmark measured 142 ms p50 and 155 ms p95. Its er-dev release then rolled back when the er-tenant-migrate post-upgrade job hit its deadline on Nov 30. The latest published er-dev wall p95 in the 55-call series is still 972 ms for #1506. The later 306 ms prefilter and 597 ms total for #1509 are server medians. The indexed build still needs a serving-revision check and a fresh 55-call er-dev measurement before this issue can close.

    The rollout log includes a Started event for the migration container about 29 minutes before the diagnostics, followed by a controller deletion and DeadlineExceeded. Its final pod list was empty because the pod had been deleted. This establishes that the migration container ran. The retained output does not identify which migration operation consumed the time. On the next authorized deployment, retain the hook container logs while it is running so a repeat timeout can be attributed.

    The merged reference update contains the measured series and the current catalog paths. Failed er-dev rollout · Er-dev phase measurements · Indexed local benchmark

  6. athvin commented on Dec 1, 2026

    @athvin
    OwnerAuthor

    Both failed dev attempts created two tenant migration pods. Each Job had a 1,920-second active deadline, a retry limit of one and a 1,800-second application wait. Each controller recorded a second pod creation roughly two minutes after the first. Both Jobs finished with two failed pods.

    On attempt 2, the final event listing places the retry container start 29 minutes before collection and its stop 51 seconds before collection. Allowing for the minute-rounded start, it ran for less than 29 minutes 10 seconds. Even if the retry had reached the application wait immediately, it could not have reported a full 30-minute timeout before the controller stopped it. The reason the first pod ended and the tenant or stage the retry was waiting for are still unknown.

    On the next authorized er-dev deploy, capture both pod attempts from their creation and preserve the first container's exit reason and the retry's last completed migration stage. The indexed build still needs the 55-call er-dev measurement. First job and events · Retry job and events

    Retained application evidence, verified December 1. In the er-dev container archive, the first pod in each attempt reported one migration enqueued at the same catalog revision, at 19:30:12.963 and 20:05:00.130 UTC on November 30. The retry pod from attempt 2 reported the same at 20:07:55.037. The connection-refused messages from the first pods came from the telemetry exporters. No terminal per-tenant result appeared in either first pod's retained application output. I found no matching application stream for the attempt-1 retry.

    The archive is the 30-day CloudWatch group /er/dev/containers in us-east-2. For reproduction, use the CI migration pods named in the two Jobs and the CI dispatcher’s the job settled events at the UTC times below. Log retention and stream naming

    The CI dispatcher logged zero lake_migrate records during the second deploy window. At 01:37:54.593 UTC on December 1 it recorded a full pipeline job ending in failure. Four distinct lake_migrate jobs then succeeded at 01:38:32.353, 01:38:44.461, 01:38:50.626 and 01:38:58.668, all within 65 seconds of that pipeline settling. The application lines prove enqueue completed. The ordering is consistent with migrations waiting behind the dataset writer. The hook logs omit the generated job IDs, and the dispatcher settlement lines omit dataset IDs, so those logs alone cannot establish the exact blocking job or match each settlement to a hook pod. The application did not report a breaking schema in the observed hook streams. Migration enqueue and wait · Writer admission rule

    At 21:19 UTC the CI service still selected blue with one ready API replica. Its image digest matched the failed deploy's previous live API (c4ee52d7…), while the indexed candidate in both attempts was bc45282a…. The pending check is a dev-only CI release of the candidate and the existing 5 warm-up / 55 measured requests. Capture the active job and migration job IDs on the next authorized run so writer-queue time can be established directly.

  7. athvin commented on Dec 1, 2026

    @athvin
    OwnerAuthor

    The dev-only retry of the indexed build succeeded on 1 December. Attempt 3 started at 23:05:18 UTC, the inactive-colour upgrade completed at 23:07:24, and the preview API readiness and web health checks both returned HTTP 200. CI completed the traffic switch to green at 23:07:41. The production job retains its original 30 November execution time.

    I verified the live ci/er-api service selected green, had a ready endpoint, and that its one-CPU API pod used the candidate image sha256:bc45282aa03b8da0b7fb1dfd01f798881dfeed8da84133348f5c602e7abc5c6e from f3cb5ede. This clears the deployment prerequisite. The 300 ms p95 gate still requires five warm-up requests and 55 measured resolve calls on p3live/default using the benchmark probe and an authorized viewer credential. Dev CI job and smoke checks · Indexed build

    The indexed-release test fixture supplies a reproducible HTTP probe for the next pass. Use source crm, the test’s synthetic payload as record, and limit: 10. The earlier live reports do not include their request body. Identify the probe used when posting the measurements, and keep the recorded corpus size and serving revision alongside them.

  8. athvin commented on Dec 2, 2026

    @athvin
    OwnerAuthor

    Live er-dev measurement of the indexed build: the gate is still missed, and the remaining cost is server-side. Measured 2026-12-02 04:53–04:54 UTC.

    Serving: ci/er-api selects green, which has one ready replica. The er-server container has a 1-CPU limit and runs image er-api@sha256:bc45282a…e7abc5c6e (f3cb5ede). Probe: the bundled resolve_latency_at_scale CRM record at f3cb5ede, limit: 10. Driver: 5 warm-ups and 55 timed sequential calls over a loopback kubectl port-forward. A temporary viewer key was used and has since been revoked.

    p50 p95 max
    Client wall, through port-forward 633 ms 916 ms 12,048 ms
    Server request duration (from its own log) 411 ms 433 ms —
    • All 60 calls returned 200 with decision auto_merge. Every call came from one snapshot (29533), which matched the post-run metrics.
    • The corpus is now 779,861 standardized records, not the ~520k in the issue.
    • A /healthz through the same port-forward takes 175 ms median, so most of the gap between the two rows is the tunnel. The 12 s outlier has no matching server-side trace.
    • First call: 3,409 ms server-side.

    The server-side stages, measured over the same 55 calls, show where the time goes:

    Stage p50 p95
    standardize_ms 227 253
    prefilter_ms 138 160
    predict_ms 23 —
    prepare_ms + select_ms ~17 —

    Standardizing one probe record costs more than half the request. Even with zero network cost the server alone is about 1.4× the 300 ms target. Next step: remove the per-request standardize setup cost, then re-measure.

  9. athvin commented on Dec 2, 2026

    @athvin
    OwnerAuthor

    #1515 is live on er-dev; the gate is still missed. Standardize is fixed; the prefilter now dominates. Measured 2026-12-02 06:36 and 06:38 UTC.

    Serving: deploy 46825081522 logged deploying a1dd29d5, and ci/er-api now selects blue (er-api@sha256:6edf36df…, one 1-CPU replica). The driver, probe and corpus were the same as before: 779,861 records, snapshot 29533, verified after each pass. Each pass used a temporary viewer key, revoked afterwards.

    Before (f3cb5ed) After, pass 1 After, pass 2
    Client wall p50 / p95 (port-forward) 633 / 916 416 / 515 413 / 459
    Server request duration p50 / p95 411 / 433 240 / 344 —
    resolve timings total p50 / p95 411 / 433 195 / 287 197 / 227
    standardize p50 227 28.3 28.9
    prefilter p50 / p95 138 / 160 123 / 185 125 / 152
    prepare / predict / select p50 5 / 23 / 11 5 / 24 / 12 —
    • Standardize: the staged rendering removed 199 ms per call, as predicted from the local repro.
    • Prefilter: the EFS file-cache claim did not hold. It fell only 11% and is now ~63% of the resolve total. Locally the same prefilter runs in ~5 ms at 780k records, so er-dev is ~25× slower for this stage. The next diagnosis is whether that is I/O against the EFS-backed corpus (is the cache actually hit?) or CPU on the 1-CPU pod.
    • Outside the resolve stages: the handler spends ~45 ms (request 240 vs resolve 195 at p50): authentication, input loading, serialization.
    • Memory: er-server went from 721 to 729 MiB over 60 calls, so the per-call leak is gone.
    • Measurement method: ci/er-api is ClusterIP-only. The driver opens a new connection per call through a kubectl port-forward whose /healthz floor is 168 ms from this client, so the wall numbers above include that tunnel. Once the server side is clearly under the gate, the wall measurement should come from a client that doesn't pay a per-call tunnel.
  10. reopened this on Dec 2, 2026
  11. athvin commented on Dec 3, 2026

    @athvin
    OwnerAuthor

    The gate is met on er-dev with #1518: in-cluster wall p95 is 116.7 / 120.6 ms at 779,861 standardized records, against the 300 ms target. Measured 2026-12-03 00:47–00:58 UTC.

    Release (dev only). The owner limited #1518 to er-dev, so this went out through the new dev-only dispatch from #1545:

    Wall latency. 5 warm-ups + 55 sequential calls per pass, the same probe (resolve_latency_at_scale CRM record at f3cb5ede), the same nearest-rank p95 (53rd of 55), a temporary viewer key (revoked).

    Client p50 p95 max
    In-cluster (Node fetch in the pod's web container → er-api.ci.svc), pass 1 107.6 116.7 142.9
    In-cluster, pass 2 106.2 120.6 130.3
    Laptop through kubectl port-forward (tunnel floor now 250 ms), pass 1 / 2 352 / 359 368 / 383 374 / 622

    All 220 calls returned 200 with decision auto_merge on snapshot 29533, which matched the post-run /metrics. The port-forward rows are almost entirely the tunnel; the in-cluster rows are what a client of the service sees.

    Server stages over 110 warm calls (resolve timings, plus the new resolve request timings line):

    #1515 (before) #1518
    Request handler p50 / p95 240 / 344 103 / 112
    Resolve total p50 / p95 195 / 287 83 / 92
    prefilter p50 / p95 123 / 185 15 / 19
    standardize p50 28 26
    predict / select p50 24 / 12 23 / 12
    auth p95 — 17

    Cold start. resolve corpus cached built the in-memory corpus copy once: 5.54 s, 779,861 rows, 334.6 MiB. That first call took 5.85 s.

    Open until #1518 lands. Dev now runs an unmerged image; the next merge-triggered deploy puts dev back on main's code. Prod still runs #1515. Close this issue when #1518 merges, with prod rollout approved, and its ledger records the same check on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions