Skip to content

perf(reconcile): build the incremental overlap matrix in one pass over the members (#1424) - #1427

Merged
athvin merged 1 commit into
mainfrom
perf/1409-incremental-overlap
Nov 29, 2026
Merged

athvin merged 1 commit into
mainfrom
perf/1409-incremental-overlap

Conversation

@athvin

@athvin athvin commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Closes #1424

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

What

reconcile_plan's overlap matrix is built in one pass over the members through a record → old-entities index, instead of intersecting every new group with every old entity.

Why

Found by #561's live proof on er-dev. After #1417 a full reconcile of 260k takes seconds, but an incremental one (a second 260k delivery over the first) still ran past 15 min at 100% of one CPU. A local sample put it all in reconcile_plan: groups × entities BTreeSet intersections, about 6.8×10¹⁰ and almost all empty.

Proof

make check exit 0 before the rebase. The rebase crosses only #1425 (scripts) and #1421 (test fixtures), no shared code. New overlap_matrix_equals_the_pairwise_definition checks equality with the old pairwise definition, including a record in two entities, a departed record and new records. er-reconcile's goldens and the er-cli lake tier (68/68) pass. Local repro, debug build: incremental reconcile of 260k over 260k went from never finishing (sampled, then killed) to 27.7 s.

Risk & rollback

The output is identical by construction, and the test pins it. Rollback: git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on brians-MacBook-Pro · 2026-11-29T10:41:50Z

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

The index keeps every entity a record is in, so the result equals the pairwise definition even if p_old were not a partition.

🤖 Generated with Claude Code

…r the members (#1424)

reconcile_plan's overlap matrix intersected every new group with every
old entity: groups x entities BTreeSet intersections, almost all empty.
An incremental reconcile of a 260k delivery over a 260k corpus therefore
ran past 15 minutes on er-dev at 100% of one CPU, after #1417 had already
made the full path take seconds. Found by #561's live proof; a local
sample of the incremental run showed it all in reconcile_plan.

overlap_matrix now indexes each record's old entities once and drops
each new group's members into their cells: O(total members). The index
keeps every entity a record is in, so the result equals the pairwise
definition even if p_old were not a partition.
overlap_matrix_equals_the_pairwise_definition pins that, including a
record in two entities, a departed record and new ones.

Local repro (debug build): an incremental reconcile of 260k over 260k
went from never finishing (sampled, then killed) to 27.7 s. er-reconcile's
goldens and the er-cli lake tier (68/68) pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit b2bdf35 into main Nov 29, 2026
44 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 29, 2026 09:36 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — d423a9ad Deployed Nov 29, 2026 by athvin via remove closed PR previews #156
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.

Incremental reconcile is O(groups × entities): every new group intersected with every old entity

2 participants