Skip to content

Emit replayable pcbTracePaths in autorouting end events - #4164

Open
seveibar wants to merge 1 commit into
mainfrom
feat/autorouting-event-pcb-trace-paths
Open

seveibar wants to merge 1 commit into
mainfrom
feat/autorouting-event-pcb-trace-paths

Conversation

@seveibar

@seveibar seveibar commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Emit JSON-serializable pcbTracePaths on local autorouting:end events so CLI and browser consumers can save routes without walking live components, reading private placement methods, or diffing accumulated SRJ traces. Each array contains the current stage's copper and can be passed to the corresponding <autoroutingphase pcbTracePaths={savedPaths} /> with the same phase options and placement.

Core resolves port selectors and local coordinates, orders multi-terminal routes, and validates the complete array through the saved-path importer. Export and import share the placement transform. Unrepresentable output emits pcbTracePathsUnavailableReason instead of partial paths or a routing error. Cached and precomputed results are covered. This is separate from the event-index correction in #4163.

Performance

Generation is always on. On Apple M3 Pro / Bun 1.3.2, 100 iterations after 10 warmups measured:

Fixture Export median / p95 JSON serialization median
One routed connection 0.049 / 0.108 ms 0.0011 ms
Dense RP2040, 18 connections / 475 points 1.281 / 1.802 ms 0.0665 ms
Synthetic 64-connection scaling case 0.808 / 0.936 ms 0.0268 ms

The dense routing stage took ~3,744 ms; median export cost is ~0.034% of that duration. The exported JSON is 46,753 bytes. These small absolute costs support generating paths for every completed local stage. Measurements are warmed microbenchmarks, not a whole-render A/B test; worker transport and much larger boards may warrant further profiling. The synthetic case uses a simple custom router, so its routing duration is not used as a performance baseline.

Reproduce with BENCHMARK_PCB_TRACE_PATHS=1 bun test tests/benchmarks/autorouting-phase-pcb-trace-paths.test.tsx. Details and limitations are in docs/autorouting-event-pcb-trace-paths.md.

Replay parity

The dense RP2040 + flash + USB-C fixture routes 18 connections across crowded pads, obstacles, layers, and vias. A fresh circuit replays the JSON-serialized event paths without running the autorouter. Observed raster parity: 100% overall and 100% foreground, with zero differing pixels.

The test requires >=99.99% full-image and >=99.9% foreground parity, verifies trace/via counts, and removes a trace as a negative control. It includes this checked-in side-by-side SVG:

Autorouted and replayed dense RP2040 PCB

Fanout exports preserve saved escapes; the follow-up autorouter can choose different geometry for unsaved copper. The fanout test checks parity of the exported copper specifically. Jumper/through-obstacle segments and non-port junctions that cannot be represented by the saved-path API are reported explicitly.

Validation: 23 phase/cache tests pass (including the new parity, transforms on both layers, fanout, cache, and unsupported-output tests), benchmark passes, TypeScript checking passes, build passes, and changed-file formatting passes.

CI note: test shard 10 reports the same two existing routing DRC failures as #4163: usb-c-breakout-net-pair and repro-am62l-direct-decoupling-fanout. Both were reproduced on unchanged base commit f3adb5e, including AM62L's expected 48 / actual 51 trace errors. These baseline failures are not changed by this PR. Formatting, typecheck, smoke test, and the other completed shards pass.

@vercel

vercel Bot commented Sep 26, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
tscircuit-core-benchmarks Ready Ready Preview Sep 26, 2026 7:39pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — a6687cf3 Deployed Sep 26, 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.

1 participant