Generate the guide, walkthrough, and gallery figures from one command. Keep benchmark fixtures and attribution with the tests and fold the durable findings from completed plans into the guides.
90 lines
8 KiB
Markdown
90 lines
8 KiB
Markdown
# Routing diagnostics and metrics
|
||
|
||
Investigate changes in planner selection, coverage, or runtime.
|
||
|
||
- [Layout troubleshooting](user/tune-and-troubleshoot.md)
|
||
|
||
## Automatic reports
|
||
|
||
- **A net is missing.** Compare verified count with `max_routed`. In `stages`, find where coverage stops increasing and check skipped or locked nets.
|
||
|
||
- **The chosen route changed.** At `stages[selected_stage]`, `planner` names the candidate producer and `mode` names the worker that handled it. Use `planner_rejections` to inspect failed plans.
|
||
|
||
- **The run slowed down.** Group `timings` by policy and operation, including failed attempts. Each duration excludes nested operations. Compare stage work with `run.metrics` and total time with `duration_s`.
|
||
|
||
## Route metrics
|
||
|
||
Use repeated wall times to check whether counter changes affect runtime.
|
||
|
||
| Observation | What to check next |
|
||
| --- | --- |
|
||
| More expansions and a later selected stage | Compare the node counts and verified IDs of each stage. The original work may have moved into a fallback. |
|
||
| Similar expansions, more search time | Check `ray_cast_calls*` and `ray_cast_exact_geometry_checks` for visibility work. Compare dynamic `congestion_candidate_ids` with `congestion_exact_pair_checks` to see how much candidate geometry reaches exact tests. |
|
||
| Verification dominates | Compare `verify_path_report_calls` with `verify_static_buffer_ops` and `verify_dynamic_exact_pair_checks`. This can distinguish repeated path checks from expensive checks of the same paths. |
|
||
| Refinement takes longer | Compare `refinement_windows_considered`, `refinement_candidates_verified`, and `refinement_candidates_accepted`. Check whether the added windows buy a better path before enlarging the default budget. |
|
||
| Attempts reach targets while verified coverage stays flat | Compare `iteration_conflict_edges` and `nets_carried_forward`. After congestion iterations finish, check how many pair repairs were tried and how many were installed. `pair_local_search_nodes_expanded` counts expansions from every pair-local search and is included in `nodes_expanded`. Use `pair_local_search_attempts` to count every try. |
|
||
|
||
`nets_routed` and `nets_reached_target` count attempts. Use `result.is_valid` or `verified_net_ids` for final successes.
|
||
|
||
`timeout_events` counts routing workers that reached their deadline. Frontier diagnostics use the time left after routing and final verification. They gather component details for colliding nets and check the deadline during that work and during frontier replay. `diagnostic_timeout_events` counts workers where the deadline stopped or skipped frontier diagnostics. A diagnostic timeout leaves the routing result, retry decisions, and replay callback intact.
|
||
|
||
- [Full metrics field list](../inire/results.py)
|
||
|
||
Exact corner visibility uses cached local queries. Track them with `visibility_corner_queries_exact` and `visibility_point_cache_hits`. The legacy graph counters `visibility_builds` and `visibility_corner_pairs_checked` report zero, as do `ray_cast_calls_visibility_build` and `ray_cast_calls_visibility_query`.
|
||
|
||
Search bounds the two move caches by entries and polygon coordinates. It drops the corresponding static-admission keys when evicting positioned moves. An unusually large live frontier drops dominated nodes and retains the best 40,000 entries once it exceeds 50,000. Check `frontier_trim_events` and `frontier_nodes_discarded` when diagnosing a large failed attempt.
|
||
|
||
## Traces
|
||
|
||
Enable the `DiagnosticsOptions` flag for the question you want to answer.
|
||
|
||
Returned traces describe the selected attempt. Numbered entries use the same run-wide indices as progress callbacks. A timed-out iteration can consume an index without calling back. Work counters include all attempts. Reroute scheduling tracks its own effort from node expansions and uncached congestion queries.
|
||
|
||
| Question | Flag and result |
|
||
| --- | --- |
|
||
| Which net consumed an iteration's budget? | `capture_iteration_trace` records `iteration_trace`. Inspect per-net `net_attempts` for expansions, pruning, congestion calls, and seed usage. |
|
||
| Which routes have a clearance conflict? | `capture_conflict_trace` records the conflicting net IDs and the component indices in `conflict_trace`. |
|
||
| Which candidate moves were pruned near the conflict? | `capture_frontier_trace` records `frontier_trace` for routes that reached their targets and still conflict with other nets. The trace samples moves and their prune reasons during a replay. |
|
||
| What layout did the worker restore for pair-local repair? | `capture_pre_pair_frontier_trace` records the selected congestion iteration, its reroute order, conflict edges, and work. The worker saves that layout and replays it after repair and verification. A conflicting net carried from an earlier iteration has zero attempt work for the selected iteration. |
|
||
| Where did detailed search explore? | `capture_expanded` records positions and headings from the detailed routing iterations in `expanded_nodes`. Use `plot_expanded_nodes()` as in the [fan-out script](../examples/07_large_scale_routing.py). |
|
||
|
||
<a id="find-overlapping-components"></a>
|
||
|
||
### Find components in conflict
|
||
|
||
1. Enable `capture_conflict_trace` in `DiagnosticsOptions`. In `run.conflict_trace`, choose the entry with `stage="final"` to inspect the returned paths, including nets verified and locked before the selected search.
|
||
2. Find the two net IDs in `conflict_edges`. In the matching `nets` entry, read `component_conflicts` for `self_component_index`, `other_net_id`, and `other_component_index`.
|
||
3. Use those zero-based indices to look up components in each net's `path` in `run.results_by_net`. Plot their physical shapes and compare the distance between them with the [required clearance](architecture.md#geometry-and-refinement).
|
||
|
||
An earlier entry such as `restored_best` indexes the paths at that stage. Use the paths from the same stage for a geometry comparison. If verification failed with an empty conflict edge list, check the net's report for a keepout conflict, self-collision, or board boundary violation.
|
||
|
||
### Follow a late conflict into pair-local repair
|
||
|
||
Capture the conflict trace for fan-out with warm starts disabled. The best congestion iteration leaves two disjoint pairs of nets competing for space.
|
||
|
||
The [fan-out regression](../inire/tests/test_example_regressions.py) enables these traces and checks the restored and final layouts. To inspect its result from a checkout, run this Python snippet.
|
||
|
||
```python
|
||
from inire.tests.example_scenarios import trace_example_07_no_warm_start
|
||
|
||
run = trace_example_07_no_warm_start()
|
||
for entry in run.conflict_trace:
|
||
if entry.stage in ("restored_best", "final"):
|
||
print(entry.stage, entry.completed_net_ids, entry.conflict_edges)
|
||
```
|
||
|
||
1. At `restored_best`, six nets verify. The conflicts are `net_02`–`net_03` and `net_06`–`net_07`.
|
||
2. At `final`, all ten nets pass verification after repair and the list of conflict edges is empty.
|
||
3. Inspect `run.iteration_trace` for expansion and congestion counts and `run.pre_pair_frontier_trace` for reroute order and per-net work before repair.
|
||
|
||
Use the returned result to count final successes. For live progress during routing, pass an [`iteration_callback`](user/api-reference.md#route-a-problem).
|
||
|
||
## Reproduce and compare
|
||
|
||
1. Start with the same fixture and options in both revisions. Run the relevant [regression tests](benchmarks.md#run-a-benchmark).
|
||
2. For a change intended to preserve routes, compare the verified IDs, move sequences, effective ports, and physical geometry in the returned results. Include stage records, callbacks, or traces when the change touches them.
|
||
3. For a change to routing policy, compare verified IDs, paths, and per-net costs first. Then run the corpus and relevant holdouts. Use interleaved repeats for timing, and inspect operation timings when runtime changes without a corresponding change in expansions.
|
||
|
||
### Check timing and counters
|
||
|
||
Run the timing gates with `INIRE_RUN_PERFORMANCE=1 python -m pytest -q inire/tests/test_example_performance.py`. Use the work counters above to investigate a slower case.
|