Skip to content

perf(synth): shard near-duplicate signing across the resolver pool - #609

Merged
bompus merged 4 commits into
fork/consolidatedfrom
perf/near-dup-shard
Nov 1, 2026
Merged

bompus merged 4 commits into
fork/consolidatedfrom
perf/near-dup-shard

Conversation

@bompus

@bompus bompus commented Nov 1, 2026

Copy link
Copy Markdown
Owner

What changed

  • refreshNearDuplicates is async and accepts a sign dependency. A full index now signs bodies on the resolver pool after synthesis, while the pool is still open and idle, instead of on the main thread.
  • New ResolverPool.signNearDuplicates worker task: workers read the bodies from disk, compute shingles/signatures and return both the MinHash bytes and the shingle set.
  • The post-synthesis hook runs inside resolveAndPersistBatched, before the pool is destroyed; indexAll skips its separate near-dup pass. Sync keeps the in-process path (no pool, small changes).
  • The signed shingle sets are kept as Uint32Arrays and a Set is built only for a body that actually lands in a candidate pair, avoiding 36k main-thread Set rebuilds.
  • New fake-signer parity test in near-duplicates.test.ts (in-process signer stores the same signatures and pairs).

Measured (interleaved, admission passed)

Corpus Arm nearDuplicates Total
n8n base 1,459 / 1,461 ms 52.79 / 52.90 s
n8n signer 860 / 894 ms 52.43 / 52.98 s
supabase base 593 / 602 ms 16.68 / 16.71 s
supabase signer 338 / 355 ms 16.42 / 16.50 s
  • n8n: the phase drops ~0.6 s but the total is flat inside the base spread.
  • supabase: the phase drops ~0.25 s and the total is 1.4% faster, consistent across runs.
  • Pairs are unchanged (1,374 n8n / 895 supabase) and supabase's edge SHA is identical in every run.

Scope / risk

  • Only the full-index path uses the pool signer; a run without a pool (small index, CODEGRAPH_NO_PARALLEL_RESOLVE=1) falls back to the in-process loop.
  • A signer failure falls back to the in-process path; it never fails the index.
  • The async refresh changes the call sites (indexAll, sync, the tests) and adds a worker message; the parity test and full suite cover the result.

Tests

  • near-duplicates.test.ts: 9/9, including the fake-signer parity case.
  • Full npx vitest run: 958 files, 11,345 passed, 46 skipped, 0 failed.

README impact

The README measured-results table predates this change; supabase's 17.37 s row will move. Re-measuring the corpora is heavy and is recorded as a follow-up rather than hand-editing one row.

@bompus bompus added the author:deepseek Pull request written by a deepseek model label Nov 1, 2026

@bompus-ai-review bompus-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bompus AI Review (GPT-6.1 Terra, max reasoning): 1 finding(s).

Comment thread src/graph/near-duplicates.ts Resolved
…ails

Review of #609: a rejected pool/worker signing task left the stale
bodies unsigned and the pairs stale. Catch the rejection and run the
same in-process loop the no-pool path uses, logging under
SYNTH_TIMINGS. The new test forces a rejecting signer and asserts the
rows and pairs match the in-process result.

@bompus-ai-review bompus-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bompus AI Review (GPT-6.1 Terra, max reasoning): 1 finding(s).

Comment thread src/codegraph.ts Resolved
Review of #609: the post-synthesis hook set the instance field true and
a later indexAll on the same CodeGraph instance skipped the fallback
even when the hook did not run (no refs, no pool, resolver skipped).
Reset it at the start of each full index.

@bompus-ai-review bompus-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bompus AI Review (GPT-6.1 Terra, max reasoning): 0 finding(s).

Review 3: only high findings and above are posted from here on.

@bompus
bompus merged commit fbda999 into fork/consolidated Nov 1, 2026
3 checks passed
@bompus
bompus deleted the perf/near-dup-shard branch November 1, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:deepseek Pull request written by a deepseek model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant