Repository navigation
perf(knowledge): reconcile a completed listing in one pass over its windows - #9449
Merged
Merged
Conversation
…indows The reconciliation count read every window of a connector, then the ACL, soft-delete and hard-delete walks each read the same windows again. The tally now counts every decision input and keeps the rows each removal acts on in the same window statement, so removals page through those rows instead of walking the connector again. A condition matching more than 10,000 documents keeps only its count and falls back to the existing walk, so memory and each statement's result stay bounded.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryCompleted listings now count documents and retain removal candidates during one windowed pass.
No actionable issues were found. Tests were inspected but not run during this review.
|
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.
Summary
tallyReconciliationWindowsreplacescountReconciliationWindows: the same one-statement-per-window keyset walk overdoc_connector_reconciliation_v2_idxnow also returns, per condition, the ids (and tombstone flag) of the matching rows, each condition evaluated once per rowvisitReconciliationMatchespages those retained rows to the existing removal callbacks, so a completed listing reads each window once; the walks stay only as the fallback for a condition matching more thanRECONCILIATION_RETAINED_MATCHES(10,000), which keeps memory and each window's result boundedLimit 1probe ofdoc_connector_reconciliation_v2_idxwith no otherdocumentaccess, plus an in-memory sort of the window. A cold window is I/O-bound (~1.3s, nearly all of it reads), a warm one ~47mssource_seen_atstays out of every index (HOT updates), member-resurrection walks, statement timeoutsType of Change
Testing
sync-content-pass.integration.ts(real Postgres) gains a suite for the removal decisions: under, at and over the cap for soft, hard and both together (exact hold notices, ACLs revoked either way), full sync past the cap, an empty connector, a connector of three windows (exact soft/hard/ACL sets, 3 tally statements and no walks), more than 10,000 removals (walk fallback, each purged exactly once in pages of 25), a user excluding a tallied document mid-pass (skipped) and one in a later window (never counted), and a deadline cut mid-removal resumed by the next pass (each removed once)listing-continuation.integration.tsreconciliation-window tests now assert no walks and keep the EXPLAIN ANALYZE bound (every tally statement reads at most one window) on the real schemareconciliation-window.test.ts(sums and retains across windows, bound edge), plus the updatedsync-content-pass,sync-engineand member-sync-engine tests;vitest run lib/knowledge(1,793 tests)bun run lint,bun run type-check,bun run check:audits,check:test-types, block-registry checkChecklist
test-auditauthoring gate)