Skip to content

Reuse regional geometry and owned route metadata - #279

Merged
imrishabh18 merged 16 commits into
mainfrom
perf/reuse-untouched-region-caches
Oct 22, 2026
Merged

imrishabh18 merged 16 commits into
mainfrom
perf/reuse-untouched-region-caches

Conversation

@imrishabh18

@imrishabh18 imrishabh18 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Port-point routing repeated static neighbor checks throughout each owned search, and selective rerips rebuilt intersection geometry even in untouched regions. Reuse both forms of stable state while preserving the selected paths, ordering, routing work, and invariant checks.

Visual snapshots

PNG previews of the checked SVG regression snapshots, generated from the live reference and optimized test observations.

Regional metadata reuse. The port heatmap records 1,447 → 82 hop-ID evaluations over 50 paired steps with identical state and stats.

Visual snapshot: Regional metadata reuse

SVG snapshot · Snapshot test

Selective region rebuilding. Ripping route 0 changes only region 0: rebuild one segment instead of five while retaining the same committed copper.

Visual snapshot: Selective region rebuilding

SVG snapshot · Snapshot test

The SVGs are regression-tested; the PNGs above are rendered from those exact checked-in SVGs for inline display.

  • Reuse intersection caches when a selective rerip removes no segment from a region. Refresh their scores with the current geometry and cost parameters; continue validating every committed port owner.
  • Lazily cache successful section, incidence, hop-ID, assignment, and reservation checks inside the existing opt-in OWNED_REGIONAL_HOP_FRONTIER contract. Live closure, best costs, congestion, penalties, and scoring still run for each candidate. Lazy preparation preserves early-goal and exception order.
  • Invalidate retained metadata when the heap, closure epoch, route, net, goal, best-cost generation, or neighbor-array identity changes. The existing ownership contract requires fixed ordinary metadata within an epoch; the default and opt-out search paths are unchanged.

The neighbor metadata idea is adapted from #208. This patch isolates cache reuse; it excludes that PR's owner-floor, dominance-pruning, and tie-order changes.

Validation with snapshot regression coverage (production unchanged from benchmarked bee74730028acc3fe72a1132bef3ef89df0238d7):

  • All 152 tests pass with 2,889 assertions; TypeScript and changed-file formatting checks pass.
  • Differential tests compare working state, subsequent output and iterations, native closure, queue replacement, best-cost resets, route/net/goal boundaries, neighbor replacement, no-op and selective rerips, shared endpoints, recommits, and loud ownership errors. Existing malformed-incidence, early-goal, and scoring-error cases preserve the exact exception order and messages.
  • A work-count replay of the actual current autorouter's SRJ18 sample 6 retains the exact port-output SHA-256 b6d233e9f40324bacc9393ce4038ec8ec155cc91433b083d49a392546681e860, every non-timing solve-graph metric, all 2,000,000 inner iterations, and all 5,683,414 frontier expansions.
  • In that replay, hop-key evaluations fall from 355,788,254 to 28,854,609 (91.89% fewer), port-reservation checks from 351,821,820 to 28,855,122 (91.80% fewer), and region-reservation checks from 338,725,099 to 15,758,401 (95.35% fewer). The 330,211,264 best-cost checks and 79,581,560 scoring calls remain identical. This omits 972,867,041 repeated static helper calls.

SRJ18 regional port pathing takes 5.97% less time overall and 13.43% less on sample 6 in the combined consumer benchmark. The combined consumer patch is benchmarked in tscircuit-autorouter #3160: 107 scenarios on paired Blacksmith ARM runners, unchanged effort/search limits, all 106 completed route SVGs byte-identical, and no new completion or DRC failures. The five completed selected SRJ28 cases take 19.26% less total time (3.15% including the unchanged timeout); the heaviest completed case is 39.16% faster and reproduces a 37.01–44.80% speedup in a four-pass order control. Dataset01 is 2.92% faster in one paired run, while SRJ18 total time is effectively flat. These end-to-end figures measure the combined solver changes; they are not isolated attribution to this PR. Peak RSS is mixed and variable, including a 19.24% increase for sample 37 in the primary run that does not consistently reproduce in the order control. No uniform RSS reduction is claimed. Full per-case results, quality checks, memory quantiles, limitations and workflow links are in the consumer PR.

Snapshot regression coverage now records both optimizations with the original behavior as the live oracle:

  • Owned-metadata snapshot: 1,447 → 82 hop-ID evaluations in the uninterrupted case, plus explicit queue-clear, best-cost-reset and neighbor-replacement cases. Every compared routing step still has equal state and stats.
  • Selective-rerip snapshot: ripping route 0 rebuilds one segment instead of five, identifies reused geometry regions, and retains the same committed routes. The test also checks subsequent routing, scalar cost refreshes and ownership errors.

These follow-up commits change only tests and checked-in deterministic snapshots. Production code and dependency pins are unchanged from the benchmarked revisions. The snapshots record operation counts rather than elapsed time. All four dependency solver suites (500 passing tests), all five repository type checks, and the autorouter goal regression pass locally.

Visual follow-up validation: all 500 dependency solver tests pass locally with four existing skips; all five repository type checks and the autorouter visual regression pass. Solver production code and runtime dependency pins are unchanged. The existing local formatter is pinned to Biome 2.5.15 for reproducible CI checks.

Formatting reproducibility: the floating Biome range began resolving 2.6.2, which introduced Markdown/YAML formatting failures in unchanged files. Pinning the locally validated 2.5.15 retains all format checks and keeps this PR focused on the solver and visual tests.

@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tiny-hypergraph Ready Ready Preview Oct 21, 2026 12:54pm UTC

Request Review

@tscircuitbot

Copy link
Copy Markdown

Benchmark This PR

Run benchmarks by commenting on this PR:

/benchmark [benchmark.sh args...]
/benchmark --dataset <hg07|srj18> --limit <n> --solver <core|poly> --families <default|default+deep|all> --concurrency <n|auto>

Everything after /benchmark is forwarded directly to ./benchmark.sh.
Every command runs current main and the PR head sequentially on the same Blacksmith machine, then reports their results side by side.

Examples:

  • /benchmark -> all committed completed SRJ18 Pipeline7 cases, core solver
  • /benchmark --limit 4 -> first four committed Pipeline7 cases
  • /benchmark --dataset srj18 --concurrency auto -> srj18 samples with runner CPU-count concurrency
  • /benchmark --sample sample003 -> one committed SRJ18 Pipeline7 case
  • /benchmark --dataset hg07 --limit 20 --solver poly -> first 20 hg07 samples with the poly solver
  • /benchmark --dataset hg07 --limit 40 --families default+deep -> first 40 hg07 samples with deeper candidate families

Any PR whose title contains [BENCHMARK TEST] will automatically run the benchmark workflow on PR updates.

Adapt only route-neighbor metadata reuse from #208. Prepare metadata lazily in original scan order within the existing owned-frontier contract; preserve dynamic closure, costs, candidate ordering, search budgets, and blocker-label behavior.
@imrishabh18 imrishabh18 changed the title Reuse untouched region caches during selective rerips Reuse regional geometry and owned route metadata Oct 20, 2026
@imrishabh18
imrishabh18 merged commit b20a36f into main Oct 22, 2026
7 checks passed
@imrishabh18
imrishabh18 deleted the perf/reuse-untouched-region-caches branch October 22, 2026 16:36
@tscircuitbot

Copy link
Copy Markdown

Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


This branch was successfully deployed

1 active deployment
Preview — 30ecfc23 Deployed Oct 21, 2026 by vercel[bot]
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.

3 participants