Skip to content

Replace sparse candidate maps with a bounded typed table#130

Closed
AnasSarkiz wants to merge 1 commit into
tscircuit:mainfrom
AnasSarkiz:agent/sparse-candidate-cost-table
Closed

Replace sparse candidate maps with a bounded typed table#130
AnasSarkiz wants to merge 1 commit into
tscircuit:mainfrom
AnasSarkiz:agent/sparse-candidate-cost-table

Conversation

@AnasSarkiz

Copy link
Copy Markdown
Member

Summary

  • replace the two long-lived sparse candidate-cost Maps with one generation-scoped open-addressed typed table
  • preallocate from the legal incident-hop count and retain keys across route resets without retaining stale costs
  • validate every newly observed hop and fail loudly on non-incident hops or exhausted capacity
  • leave dense candidate storage, routing costs, queue ordering, rerip behavior, and solver options unchanged

Root cause

Sparse mode advanced a generation counter on every route search, but both Maps retained every hop ever visited. Large SRJ18 boards therefore accumulated stale entries across rerips and paid two Map lookups for every candidate-cost access.

Validation

  • bun test --timeout 9999999: 98 pass, 0 fail
  • bun run typecheck
  • bun run build
  • Biome formatting check on all changed files
  • tiny-hypergraph SRJ18 benchmark: exact main parity at 4/6 successes, 0.447 average final max-region cost, and 0.031 average delta; the same two samples fail static reachability
  • isolated Pipeline 7 tiny phase on SRJ18 samples 1, 6, 12, 14, and 15: 193.75s -> 157.03s aggregate (19.0% faster), with all samples solved and the same iteration limits/output hashes
  • linked autorouter focused SRJ18 sample006 test passes; autorouter production build passes
  • autorouter full suite: 398 pass, 55 skip; seven visual snapshot mismatches reproduce with identical percentages against the package.json-pinned main dependency and are unrelated to this change

Compatibility

This branch starts directly from current upstream main. It contains no prior experimental routing commits and introduces no new public solver option or package export.

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
tiny-hypergraph Ready Ready Preview, Comment Jul 16, 2026 8:29pm

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.
The result comment shows the matching dataset from the latest stored main-branch benchmark artifact beside the PR run; main is not rerun for each PR benchmark request.

Examples:

  • /benchmark -> hg07, all samples, core solver
  • /benchmark --dataset srj18 --limit 20 -> first 20 srj18 samples
  • /benchmark --dataset srj18 --concurrency auto -> srj18 samples with runner CPU-count concurrency
  • /benchmark --sample sample002 -> one hg07 sample
  • /benchmark --limit 20 --solver poly -> first 20 hg07 samples with the poly solver
  • /benchmark --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.

@AnasSarkiz

Copy link
Copy Markdown
Member Author

/benchmark --dataset srj18

@AnasSarkiz

Copy link
Copy Markdown
Member Author

Superseded by #132, a fresh latest-main branch with the profiled candidate-cost hot-path fix and no sparse-storage experiment history.

@AnasSarkiz AnasSarkiz closed this Jul 17, 2026
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.

2 participants