Skip to content

perf(sync): index the synthesis-touch check through edges.provenance - #581

Merged
bompus merged 2 commits into
fork/consolidatedfrom
perf/sync-gate-query-cost
Oct 28, 2026
Merged

bompus merged 2 commits into
fork/consolidatedfrom
perf/sync-gate-query-cost

Conversation

@bompus

@bompus bompus commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • The perf(sync): gate synthesized-edge refresh to edits that can affect it #580 gate computes filesTouchingSynthesizedEdges() on the first changed file of every sync: two full scans of edges with a per-row json_extract — 1.98 s on n8n's 1.2M-edge table — and hasSynthesizedEdgesTouchingFile's registeredAt leg was a full scan per call (~135 ms). That scan is the n8n watchSync regression: fork ~1.9 s vs upstream ~0.97 s.
  • provenance='heuristic' is a strict superset of synthesizedBy edges (verified on the live n8n db: 21,880 ⊇ 9,490), so adding it narrows every leg through idx_edges_provenance before any JSON work.
  • Result: bulk 1978 → 32 ms, per-file leg 135 → 4 ms, identical 3,001-file result set (verified set-equal on the n8n db). Syncs checking ≤64 files now also skip the bulk set entirely and use the per-file indexed probes.

Test plan

  • 39/39 synthesis-gate tests green (sync-resynthesis, sync-rebuild-convergence)
  • Rewritten bulk query verified set-equal to the original on the real n8n db (3,001 files)
  • Typecheck + build clean
  • Fresh clean-bench watchSync row to confirm end-to-end parity

The gate added in #580 pays its check on every sync: the bulk
filesTouchingSynthesizedEdges() scanned all edges twice with a
per-row json_extract (~1.98 s on n8n's 1.2M-edge table), and the
per-file registeredAt leg was an unindexed full scan (~135 ms).
'n8n watchSync' measured the cost: fork ~1.9 s vs upstream ~0.97 s.

provenance='heuristic' is a strict superset of synthesizedBy edges,
so a provenance predicate narrows every leg through
idx_edges_provenance (~22k rows) before json_extract: bulk 1978->32ms,
per-file leg 135->4ms, same result set (3001 files verified equal on
the n8n db). Small syncs (<=64 checked files) now also take the
per-file indexed probes instead of building the bulk set at all.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bompus

bompus commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Head commit changed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

The MCP table carried bc27fdb; re-measured at 5784e28 on a clean
single-writer pass (Bun arms median of two, Node arms single). Busy
memory flipped from the run's one regression (4.54 -> 2.95 GiB vs
upstream's 3.83) and the fork now idles lower on every arm. The new
flag is Edited file re-indexed — which is the gate's own edge scan,
root-caused and fixed in this PR's provenance narrowing, not resynthesis.
@bompus
bompus merged commit 421ea88 into fork/consolidated Oct 28, 2026
3 of 4 checks passed
@bompus
bompus deleted the perf/sync-gate-query-cost branch October 28, 2026 19:00
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.

1 participant