Skip to content

perf(resolve): look up the probe's blocking keys in an index instead of scanning every corpus key (#1510) - #1512

Merged
athvin merged 1 commit into
mainfrom
perf/1429-key-index
Nov 30, 2026
Merged

athvin merged 1 commit into
mainfrom
perf/1429-key-index

Conversation

@athvin

@athvin athvin commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Closes #1510

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

  • Index the key columns. The refresh indexes each precomputed key column (__k<i>) of the cached key table.
  • Look up instead of scanning.
    • A call reads the probe's own value and type for each key once.
    • It unions one indexed equality per non-NULL key, __k<i> = CAST(value AS type), with a scan for any rule that has no precomputable key.
    • A NULL probe key matches nothing, as = would.
  • One hit query for both paths: it feeds the detached fetch (file and row) and the attached one (record_key).

Why

On er-dev e547620e (#1509), prefilter took 306 ms of a 597 ms resolve (pass-2 medians, 46 candidates). Opening fewer files didn't move it, since it was 320 ms before. The cost is the key match: the one-row probe was joined against all ~520k cached keys with an OR of equalities, a per-call scan on one core.

Proof

  • These pass:
    • a_detached_resolve_matches_the_lake_resolve;
    • resolve (8);
    • resolve_latency_at_scale, equal to the lake resolve on every call.
  • Local benchmark: p50 142 / p95 155 ms at 520k on 1 thread. The laptop's key match wasn't the bottleneck; er-dev's slower single core is where this shows.
  • Local make check couldn't complete: the host disk is at about 2 GB and Docker wedged. CI is the gate for this one.

Risk & rollback

  • Indexes: one ART index per key column on the session's temp key table, built once per refresh.
  • Rollback: 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 prefilter_ms on p3live after deploy, against 306 ms before:

🤖 Generated with Claude Code

…of scanning every corpus key (#1510)

er-dev on e547620: prefilter 306 ms of a 597 ms resolve, unchanged by opening
fewer files. The cost is the key match: the one-row probe was joined against
all ~520k cached keys with an OR of equalities, a per-call scan on one core.

- The refresh indexes each precomputed key column (__k<i>) of the key table.
- A call reads the probe's own value and type for each key once. It then
  unions one indexed equality per non-NULL key, __k<i> = CAST(value AS type),
  with a scan for any rule without a precomputable key. A NULL probe key
  matches nothing, as '=' would.
- The same hit query feeds the detached fetch (file, row) and the attached
  one (record_key).

a_detached_resolve_matches_the_lake_resolve, resolve (8) and
resolve_latency_at_scale (equal to the lake resolve on every call; local
p50 142 / p95 155 ms at 520k, 1 thread) pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit f3cb5ed into main Nov 30, 2026
43 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 30, 2026 19:24 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — eaea4dbf Deployed Nov 30, 2026 by athvin via remove closed PR previews #203
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's key match scans all corpus keys per call instead of looking up the probe's keys (#1429 follow-up)

2 participants