Record routing simplification results and prototype decisions
This commit is contained in:
parent
926b2645b5
commit
2d77877fff
2 changed files with 162 additions and 0 deletions
66
archive/routing/simplification-results.md
Normal file
66
archive/routing/simplification-results.md
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
# Routing simplification results
|
||||||
|
|
||||||
|
These checks compare the November 27, 2026 implementation with `6608e18`. The [routing simplification plan](../../plans/routing-simplification.md) defines the implementation batches and the questions each prototype tested.
|
||||||
|
|
||||||
|
## Changes implemented
|
||||||
|
|
||||||
|
| Plan items | Decision and verification |
|
||||||
|
| --- | --- |
|
||||||
|
| 1 | Reuse the live index when the last completed iteration is also the best. Timeout, an earlier winner, and a callback that edits results each exercised restoration. The change alone avoided 9,201 insertions and 9,201 removals on the public-default corpus. |
|
||||||
|
| 2–3 | Share the layout rank and stable Manhattan net order. Tests cover each ranking criterion, an empty first review, the pair-length tolerance, mixed headings, equal distances, and alternate lock order. |
|
||||||
|
| 4–6 | Represent pair targets directly and roll back only rejected installed candidates. Candidate selection uses net-level conflicts. Rejected local searches, reversed attempts, disjoint targets, and the two-pair limit were checked. |
|
||||||
|
| 7–8 | Share incumbent guidance in frontier replay and remove the unused visibility wrapper. Individual trace flags reproduced the same samples and component indices on the explicit worker runs. Exact and tangent visibility tests passed. |
|
||||||
|
| 10 | Replace only the pair under repair. The 27 explicit-worker comparisons avoided 740 insertions and 740 removals, from runs that include both fan-out seeds under five diagnostics settings. They matched paths and trace payloads through multiple repairs. |
|
||||||
|
| 11 | Reuse the best iteration's review when its geometry is still installed and no restored trace needs a capture. The earlier-winner test still performs the restored review. Final verification still supplies partial-path reports and frontier overlap details. The corpus saved 1,589 report calls, 15,582 static buffers, 32,877 dynamic candidate nets, and 13,352 dynamic exact pair checks. |
|
||||||
|
| 12 | Check for four bends before taking a path out of the index for refinement. Straight and S-bend tests confirm the installed paths stay in place. Bend-heavy fixtures kept their candidate counts and paths. Across both corpus profiles, this saved 416 refinement calls and 2,510 insertions and removals each. |
|
||||||
|
| 14 | Sample obstacle boundaries only when an enabled objective uses proximity. Bounds checks stay available. The mixed-weight test uses zero search danger and nonzero refinement danger. Pair workers use their search objective and the active greedy weight. Both profiles and the custom-bend cases matched exactly. |
|
||||||
|
| 17–20 | Reuse the prepared joint-lane problem and the common perimeter residual worker. Joint-lane lock order, skipped IDs, corridor counts, seeded IDs, and stage records matched. The forced perimeter check matched 61 stage records, including 22 residual searches and a verified two-net result on Terminal-Bench Pair. The shared objective constructor preserves each world's obstacle inputs. The containment check accepts flush ports and rejects a custom physical protrusion even when its proxy fits. The trace fixtures use the same result assembly as production. |
|
||||||
|
| 21–23 | Derive the ordinary scenario runs from the snapshot registry. Repeated selectors preserve registry order across recording and comparison, including a performance-only scenario against an older baseline. The public locked-path example matches both original path reports and the generated plot pixel for pixel. Fixture semantics stayed stable. |
|
||||||
|
|
||||||
|
## Prototypes kept out of production
|
||||||
|
|
||||||
|
| Item | Trial | Result and decision |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 9 | Explicit no-warm-start fan-out with 8 nets at seeds 41 and 44 and 10 nets at seed 43, plus mutable callbacks, caller seeds, and partial paths. | Three capped incumbents saved 15 insertions and removals each. No capped fallback ran in the two automatic corpus profiles. The hot path keeps its existing sequence. |
|
||||||
|
| 13 | Seeded alternating doglegs, return shelf, and detour under both corpus profiles, with 108 proposals near the improvement threshold. | Choices, costs, and built and accepted candidates matched. The prototype saved 1,330 component scores in six runs. Across 11 interleaved public-default repeats, the median changed from 431.2 to 430.3 ms on the doglegs, 35.1 to 34.1 ms on the return shelf, and 11.3 to 11.3 ms on the detour. Keep the simpler scoring loop. |
|
||||||
|
| 15 | A cold, bounded cache of 512 physical clearance buffers, keyed by polygon and clearance. Five interleaved public-default runs per case. | The buffer counts fell on all four cases. The largest retained geometry payload was 474 kB in WKB, before object and native memory overhead. The additional cache state has a modest end-to-end payoff. Keep the direct verification path. |
|
||||||
|
| 16 | Bypass each congestion precheck separately on offset gates, obstructed crossings, the splitter tree, and ten-net fan-out at seed 42. Five interleaved runs per case. | Skipping the grid presence check changed the fan-out expansion sequence. Skipping the candidate check added 37 congestion checks there and left the exact pair count at 5,860. The splitter tree and fan-out median gains were about 1–2%. Keep both filters. |
|
||||||
|
|
||||||
|
### Static verification measurements
|
||||||
|
|
||||||
|
| Public-default fixture | Buffer calls before → cache | Median before → cache | Retained input and buffer WKB |
|
||||||
|
| --- | ---: | ---: | ---: |
|
||||||
|
| PIC splitter tree | 1,255 → 145 | 5,258 → 5,167 ms | 474 kB |
|
||||||
|
| Alternating doglegs | 1,695 → 873 | 464 → 438 ms | 437 kB |
|
||||||
|
| Obstructed crossing approaches | 158 → 20 | 392 → 386 ms | 20 kB |
|
||||||
|
| Custom physical bend | 36 → 9 | 32.2 → 31.5 ms | 1.9 kB |
|
||||||
|
|
||||||
|
The cache trial preserved the mitred-corner distance check. The clearance and collision suites passed with the cache active, including boundary touching.
|
||||||
|
|
||||||
|
### Congestion precheck measurements
|
||||||
|
|
||||||
|
| Fixture | Grid presence rejections | Candidate rejections after presence | Mean presence / candidate query time |
|
||||||
|
| --- | ---: | ---: | ---: |
|
||||||
|
| Offset gates | 0 | 0 | No congestion queries |
|
||||||
|
| Obstructed crossing approaches | 425 | 0 | 1.42 / 2.54 µs |
|
||||||
|
| PIC splitter tree | 2,101 | 0 | 2.78 / 11.37 µs |
|
||||||
|
| Fan-out at seed 42 | 460 | 37 | 2.34 / 14.66 µs |
|
||||||
|
|
||||||
|
Query timings include cache hits and misses. In the fan-out run the envelope lookup averaged 11.28 µs and the grid-net lookup averaged 3.22 µs, inclusive of their own checks. Removing the presence filter moved work into the candidate filter and increased full congestion checks from 3,411 to 3,530. Exact tests still distinguish frozen conflicts, soft overlap, and boundary contact.
|
||||||
|
|
||||||
|
## Triggers for broader changes
|
||||||
|
|
||||||
|
**24. Residual routing.** The direct probe uses locked physical geometry and emits placeholders for disconnected IDs. A connected incumbent retry uses the same prepared residual for ordinary seeding and joint-lane recovery. The joint trial needs a seeded layout check before it can win. A disconnected incumbent instead passes movable seeds on the whole original problem. Perimeter recovery holds one local route, adds it back to the result, and verifies the whole candidate when complete. Residual dogleg generation also holds the incumbents, then checks a whole seeded layout. These flows now share preparation where their inputs match. A broader interface can wait for a recovery case that duplicates the seed merge or the whole-layout check.
|
||||||
|
|
||||||
|
**25. Collision queries.** The candidate lookup and exact overlap are already distinct steps. Candidate collection feeds both soft counts and frozen blocking, while final verification checks physical geometry and optionally records component pairs. The precheck measurements show an expansion-order dependency, and the buffer measurements show a limited benefit from adding state. Keep the current lookup boundary around `DynamicPathIndex`. Revisit it when profiling shows that the exact-test work or cache invalidation can be isolated without changing reroute work.
|
||||||
|
|
||||||
|
**26. Public options.** Keep the five routing modes and the six option groups. Constructors, benchmark profiles, and option serialization depend on the four bend geometry fields. A legacy polygon can define both proxy and physical geometry, and an explicit custom proxy keeps the standard arc unless a physical geometry is provided. The geometry overrides and the serialized benchmark cases are covered by tests. Revisit grouping with a caller-facing change that can document those cases and migrate existing constructors and fixture presets.
|
||||||
|
|
||||||
|
## Combined verification
|
||||||
|
|
||||||
|
- Both profiles verified 433 of 437 nets across 67 boards and reached each board's bound. Overloaded Gate verified 3/4 across a three-track cut. LiDAR Clements verified 3/6 with three disjoint fixed-port conflicts. The unseeded Terminal-Bench export verified 9/9 and passed the pinned upstream geometry and cost checker.
|
||||||
|
- The 134 corpus, 20 retry-holdout, and 20 focused callback and diagnostic comparisons matched their recorded paths, verified IDs, costs, stages, bounds, and trace payloads. The 27 explicit-worker comparisons also matched, including guide and seed reports and both fan-out seeds.
|
||||||
|
- The expected stable counter differences were `dynamic_path_objects_added`, `dynamic_path_objects_removed`, `verify_path_report_calls`, `verify_static_buffer_ops`, `verify_dynamic_candidate_nets`, `verify_dynamic_exact_pair_checks`, and `refine_path_calls`. The public-default corpus avoided 11,461 insertions and removals each across the combined changes.
|
||||||
|
- The complete correctness suite passed 385 tests. The separate opt-in run passed all 11 example performance tests.
|
||||||
|
|
||||||
|
The parity capture command and counter allowance syntax are in the [verification section of the plan](../../plans/routing-simplification.md#verification-and-sequencing).
|
||||||
96
plans/routing-simplification.md
Normal file
96
plans/routing-simplification.md
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
# Routing simplification plan
|
||||||
|
|
||||||
|
Reduce the amount of routing state we rebuild and the number of places that define the same policy. Start with three changes that have a small implementation scope and clear parity checks. Prototype the changes that can affect geometry ordering, cost comparisons, or search work. Keep the public routing modes, defaults, and result fields stable through these batches.
|
||||||
|
|
||||||
|
The baseline is `6608e18`. Its two regression profiles verified 433 of 437 nets across 67 boards, reached every board's routing bound, and completed Terminal-Bench at 9/9. The earlier refactor covers the existing boundaries for the search, diagnostics, and planners. Use the [historical routing refactor plan](../archive/routing/routing-refactor-plan.md) for the rationale behind those boundaries.
|
||||||
|
|
||||||
|
The implementation, parity checks, and decisions on each prototype are recorded in the [simplification results](../archive/routing/simplification-results.md).
|
||||||
|
|
||||||
|
## First implementation batch
|
||||||
|
|
||||||
|
1. **Reuse the installed paths when the last iteration is already the best.** Skip reinstalling geometry when the live index is known to represent the saved result set. Preserve full restoration after a timeout, when an earlier iteration won, and when an iteration callback is present. Exercise all three cases, including a callback that modifies the result mapping. Start with [best-iteration restoration](../inire/router/_router.py#L403).
|
||||||
|
|
||||||
|
An in-memory prototype passed all 134 corpus and 20 diagnostic comparisons after allowing changes in the two path-object counters. It avoided 9,201 removals and 9,201 insertions across the 67 public-default boards.
|
||||||
|
|
||||||
|
2. **Use one layout ranking key.** Iteration selection and pair-local repair both prefer more completed nets, then fewer conflict edges, then fewer dynamic collisions. Put those criteria in one comparison key. Preserve the path-length tie-break and its tolerance in pair-local repair. Check all three tie-breaks and the first recorded iteration before comparing the corpus. Start with [iteration selection](../inire/router/_router.py#L395).
|
||||||
|
|
||||||
|
3. **Use one stable net ordering helper.** Lattice routing, direct locking, and joint-lane recovery each implement Manhattan-distance ordering for `shortest` and `longest`. Share the sort while preserving input order for equal distances and the subsequent priority pass for direct locks. Focus the initial check on mixed headings, equal-distance nets, and alternate lock order. Compare planner stages as well as paths. Start with the [direct lock planner](../inire/router/_routing_policy.py#L77).
|
||||||
|
|
||||||
|
## Small routing and diagnostic cleanups
|
||||||
|
|
||||||
|
4. **Represent a pair of conflicting nets as two IDs.** Replace the single-field pair target class and its order helper with the existing pair of IDs. Keep the order in which targets are visited and the forward and reverse attempts. Verify the two-pair limit and disjoint-edge rule in [pair target selection](../inire/router/_router.py#L666).
|
||||||
|
|
||||||
|
5. **Restore the incumbent once after a rejected pair replacement.** An unsuccessful pair search runs in a local world. The live-world candidate check already restores the incumbent on rejection. Exercise both failure paths before removing the unconditional final reinstall. Check the live index, reports, and path-object counters after a rejection followed by a second attempt. Start with [pair replacement and rollback](../inire/router/_router.py#L761).
|
||||||
|
|
||||||
|
6. **Collect component overlaps when a report consumes them.** Pair-local candidate selection reads net-level conflicts and validity. Check whether its live-world verification can omit component details while leaving the restored and final trace captures intact. Compare exact conflict payloads with each capture flag enabled on its own. Start with [pair candidate verification](../inire/router/_router.py#L761).
|
||||||
|
|
||||||
|
7. **Share incumbent guidance in frontier replay.** Frontier replay selects reached paths and computes the same seed and bonus used for reroute guidance. Use the shared helper at that call site once the replay preconditions are confirmed. Compare sampled prune reasons and verify that the diagnostic run still leaves the selected route and production counters intact. Start with [incumbent guidance](../inire/router/_search.py#L18).
|
||||||
|
|
||||||
|
8. **Remove the unused visibility wrapper.** Delete `_ensure_current` after checking the named corner-index and corner-graph entry points. Run the visibility tests for exact and tangent modes and preserve the distinction between index-only preparation and graph construction. See the [visibility manager](../inire/router/visibility.py#L49).
|
||||||
|
|
||||||
|
## Prototypes for installed geometry and verification
|
||||||
|
|
||||||
|
9. **Keep a capped incumbent installed when the next attempt will carry it forward.** The late capped branch removes the old geometry before immediately installing the incumbent again. Prototype moving that decision ahead of index mutation when the installed path is known. Exercise late caps, partial results, caller seeds, and mutable callback results. The fallback counters and per-net trace should still describe the same attempt. Start with [routing one net](../inire/router/_router.py#L831).
|
||||||
|
|
||||||
|
10. **Keep unchanged nets in the index during pair repair.** A replacement for two nets currently rebuilds the installed set. Prototype a narrower replace and rollback for the two changed nets. Compare component indices and candidate order in conflict reports, especially with several components per net. Check rejected repairs and a successful repair followed by another pair. Accept the change if the local update stays simpler than managing the full rebuild and measurably reduces work. See [installed-path replacement](../inire/router/_router.py#L359).
|
||||||
|
|
||||||
|
11. **Reuse verified reports when the geometry and net set match.** Compare the iteration review, restored review, and final verifier. Identify where the same paths and obstacle state are checked again without an intervening repair or refinement. Preserve the final reports for partial paths and the extra details needed for frontier replay. Measure verification calls and exact checks on a clean worker run and a worker that restores an earlier iteration. Start with the [final verification path](../inire/router/_router.py#L1087).
|
||||||
|
|
||||||
|
12. **Skip refinement setup for paths that cannot supply a window.** The driver removes a path before the refiner checks whether it has enough bends. Check eligibility before removing geometry, using the same rule in direct refiner calls. Compare index updates and `refine_path_calls` on straight, S-bend, and bend-heavy fixtures. Preserve the geometry seen by a real refinement attempt. See [refinement eligibility](../inire/router/refiner.py#L317).
|
||||||
|
|
||||||
|
## Prototypes for scoring and collision work
|
||||||
|
|
||||||
|
13. **Score the changed portion of a refinement window.** Candidate scoring currently walks the prefix, replacement, and suffix for each proposal. Test whether the unchanged portions can be reused for the first cost comparison. Preserve the definitive score after materializing geometry and check floating-point ties near the improvement threshold. Compare candidates built and accepted, path cost, and score calls on long foldbacks and alternating doglegs. Start with [refinement window scoring](../inire/router/refiner.py#L267).
|
||||||
|
|
||||||
|
14. **Build the proximity tree only when a worker can use it.** Keep the board bounds check available. Skip boundary sampling when the search objective and any enabled refinement objective both have zero danger weight. For pair-local search, check the objective it actually uses. Exercise a run with zero search danger weight and nonzero refinement danger weight, and verify that custom bends and bounds behave as before. Start with [worker initialization](../inire/router/_stack.py#L34).
|
||||||
|
|
||||||
|
15. **Measure reuse of static clearance buffers.** Repeated physical verification buffers component polygons against the same clearance. Profile the buffer calls on a dense static layout and compare a small reuse experiment with its retained memory. Account for clearance, the geometry used for verification, and the exact distance check at mitred corners. Keep boundary touching and custom physical bends in the comparison. See [static path verification](../inire/geometry/collision.py#L659).
|
||||||
|
|
||||||
|
16. **Measure overlap between the congestion prechecks.** Count how often grid presence and envelope checks reject a candidate before exact tests, and how much each cached query costs. Test removal or consolidation of one layer on sparse and congested layouts where that layer contributes little. Preserve frozen-net blocking and conflict counts. If pruning pays for the extra state, record the cases that depend on it. Start with [dynamic congestion queries](../inire/geometry/collision.py#L334).
|
||||||
|
|
||||||
|
## Worker and planner setup
|
||||||
|
|
||||||
|
17. **Prepare the joint-lane residual once.** Joint-lane recovery builds a residual board for corridor planning and reconstructs it for search. Pass the prepared nets and keepouts through both operations. Compare skipped IDs, lock order, topology reports, and stage labels on the joint-lane regression test. Use the same preparation for perimeter recovery only where its inputs and result merge match. Start with [joint-lane recovery](../inire/router/_automatic.py#L538).
|
||||||
|
|
||||||
|
18. **Share worker objective initialization where the inputs match.** The ordinary worker and pair-local worker each pass the same objective fields into the evaluator. A shared constructor can lift that mapping out of both paths. Keep each worker's obstacle set explicit, including the distinction between polygons used as locks and polygons used for proximity costs. Preserve the current greedy weight during pair repair. Compare the fan-out callbacks and pair-local traces. See the [pair-local context](../inire/router/_pair_local.py#L21).
|
||||||
|
|
||||||
|
19. **Share the physical containment predicate.** Automatic trial selection and explicit bundle routing both check whether the board covers the returned path polygons. Reuse that check while retaining each caller's error or report handling. Verify designs with flush ports, a shape extending beyond the board, and a custom physical bend. Start with [automatic trial validation](../inire/router/_routing_policy.py#L245).
|
||||||
|
|
||||||
|
20. **Assemble worker results in one place.** The stack and example trace fixture both read the pathfinder's metrics, traces, and results into `RoutingRunResult`. Reuse the production assembly path and check how topology data is populated. Keep fan-out's iteration callback on its existing worker. Compare example traces and explicit guide and seed results before removing the fixture formatter. Start with [worker result assembly](../inire/router/_stack.py#L94).
|
||||||
|
|
||||||
|
## Benchmark and example tooling
|
||||||
|
|
||||||
|
21. **Derive the example runs and snapshots from one registry.** Each ordinary scenario has a run wrapper that calls its snapshot and converts the result. Share the fixture names and order between the outcome tests and the snapshot command. Preserve the timing boundaries and check every existing scenario name. Keep the heavier and trace entries available through their current selectors. Start with the [example scenario registry](../inire/tests/example_scenarios.py#L440).
|
||||||
|
|
||||||
|
22. **Share snapshot selection between recording and comparison.** Both commands select the same registry, filter by scenario, and run the selected captures. Reuse that selection and execution logic with the existing snapshot objects. Let each command keep its output schema. Check repeated `--scenario`, the working `--include-performance-only` flag, and comparison against older baselines. Start with [performance baseline recording](../scripts/record_performance_baseline.py#L13).
|
||||||
|
|
||||||
|
23. **Use the public fixed-route workflow in the locked-path example.** The example script adds a static copy of the first route to a world that still has the path installed. Route the second net with a fresh problem whose keepouts include the first route's physical polygons, as the benchmark fixture now does. Compare exact paths and the rendered plot. Explain any scoring setting needed to reproduce the detour. See the [locked-path example](../examples/03_locked_paths.py).
|
||||||
|
|
||||||
|
## Larger changes with a specific trigger
|
||||||
|
|
||||||
|
24. **Consolidate residual routing around a new recovery case.** Item 17 addresses one repeated construction. A broader interface pays off when another planner needs shared logic for frozen paths, movable seeds, or joining an unresolved result. First inventory which stages require a complete layout check and how they report skipped and unresolved IDs. Design around a concrete duplicate operation and test it across the affected planners. Use the [residual routing policy](../inire/router/_routing_policy.py#L192) as the starting point.
|
||||||
|
|
||||||
|
25. **Split collision queries along a demonstrated boundary.** Use the candidate and exact-test profiles from items 15 and 16 to identify a useful separation between lookup, exact overlap, or ray casting. Keep the hot-path call count, physical clearance, proxy geometry, and cache invalidation visible. Exercise visibility modes, rotated ports, crossing approaches, and custom polygons. Begin with the [collision query code](../inire/geometry/collision.py).
|
||||||
|
|
||||||
|
26. **Revisit public option grouping when an API change is warranted.** Consider consolidating legacy bend geometry options and grouping planner-specific fields when a caller-facing change gives that work a purpose. Inventory existing constructors, custom polygon behavior, serialized benchmark options, and documentation. Plan migration before changing defaults or removing names. Start with the [public option definitions](../inire/model.py).
|
||||||
|
|
||||||
|
## Verification and sequencing
|
||||||
|
|
||||||
|
1. Capture the current corpus with `scripts.routing_benchmark_parity capture` before starting items 1 through 3. Use both `corpus-regression` and `public-defaults`. Add a focused capture with `--callbacks` and `--diagnostics` for Terminal-Bench, obstructed crossings, the mixed port bank, and a fixture with caller seeds. Include the two no-warm-start fan-out seeds for pair repair.
|
||||||
|
2. Land items 1 through 3 as independently reviewable changes. Then group items 4 through 8 by the behavior they exercise. Tooling items 20 through 23 can proceed on their own because they have focused scenario and script checks.
|
||||||
|
3. Run the related tests and exact parity for each routing change. Compare verified IDs, paths, native and benchmark costs, selected stage, stage order, bounds, callbacks, traces, and stable counters. List intentional counter differences by name in the comparison. Use `overloaded-gate` and `lidar-clements-8x8` to check that expected geometric bounds still explain incomplete coverage.
|
||||||
|
4. Prototype items 9 through 16 separately so any route or counter difference has one likely cause. Record the fixture, profile, counts, and result for each trial. For a speed claim, run repeated wall-time measurements with matching options and worker count, and examine both the median and individual slow boards.
|
||||||
|
5. Run the full test suite and the opt-in example performance tests before combining the routing changes. Refresh an archived example baseline when fixture semantics change. Keep exploratory measurements in scratch output until they support an implementation decision.
|
||||||
|
|
||||||
|
For item 1, take the first capture at the baseline revision and the second at the candidate revision.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python -m scripts.routing_benchmark_parity capture /tmp/inire-simplification-before.json --case corpus --jobs 4
|
||||||
|
python -m scripts.routing_benchmark_parity capture /tmp/inire-simplification-after.json --case corpus --jobs 4
|
||||||
|
python -m scripts.routing_benchmark_parity compare \
|
||||||
|
/tmp/inire-simplification-before.json /tmp/inire-simplification-after.json \
|
||||||
|
--allow-counter-change dynamic_path_objects_added \
|
||||||
|
--allow-counter-change dynamic_path_objects_removed
|
||||||
|
```
|
||||||
|
|
||||||
|
For the stable comparison fields and diagnostic capture options, use the [exact parity workflow](../docs/routing-diagnostics.md#reproduce-and-compare).
|
||||||
Loading…
Reference in a new issue