Repository navigation
perf(layout): index stack alignment collisions and read stream hosts once - #568
Merged
Merged
Conversation
Count the stack-alignment collision check's rectangle comparisons in layout_bench.py, in one untimed pass, so the index can be judged independently of the machine. Add a synthetic manifold sheet and graph edge and memory columns to route_bench.py to measure how routing grows with parallel branches. Refs: #553
_straighten's horizontal pass compared every candidate move against every unit. Build a row index once before that pass, since it moves units only along x, and check each move against the units sharing its height bands. Decisions are unchanged: the same predicate runs on a superset of the units it can reject, and units with non-finite extents still meet every query. On a 1,600-block stacked sheet the checks fall from 5,123,200 to 29,251 and layout from 0.80 s to 0.31 s. Refs: #553
analyze_conflicts, _exit_conflicts and geometry_issues asked each unit for its host once per route segment. Most units have none, so every ask fell through to Unit.__getattr__ and built an error message that was thrown away. Read the hosts once per pass instead. Decisions are unchanged; routing over the examples is about 15% faster, and 25% on 11_ethanol_pid. Also clear two type-checker notes in the row-index tests. Refs: #553
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes stacked-sheet layout linear by indexing the stack-alignment collision check. It also cuts routing time by reading stream hosts once per pass instead of once per segment per unit. Every drawing is unchanged. The benchmarks now report collision checks, routing-graph size and a dense synthetic sheet.
Related Issues
Closes #553
Refs: #547, #505, #567
Changes
pandid/layout/coordinates.py: a_RowIndexfiles units by height band, built once before_straighten's horizontal pass (which moves units only along x)._overlaps_xruns the same predicate on the units sharing the mover's bands. Units with non-finite extents still meet every query.pandid/layout/conflicts.py,pandid/validate.py: read each unit'shostonce per pass. Asking per segment made every unit without a host fall through toUnit.__getattr__and build an error message that was thrown away.scripts/layout_bench.py: acheckscolumn counting collision comparisons, measured in an untimed pass.scripts/route_bench.py:--manifold Nfor a dense synthetic sheet, plusedgesandgraph MBcolumns.tests/test_layout_spatial.py: the index checked against the full scan over a compact case table, and stacked-sheet frames checked against the unindexed layout.How to Test
Run the focused tests:
Compare with
main:Run the full suite and gates:
python3 -m pytest -q python3 -m ruff check . python3 -m ruff format --check tests python3 -m mypy pandid python3 -m pyright pandidEvidence
Python 3.14.6, macOS arm64, best of 3,
mainand branch back to back:main11_ethanol_pidroutemainfor 46 drawings (21 examples as authored and with placement stripped, plus four benchmark sheets). The placement-stripped corpus still has 168 crossings.git diff --checkare clean. Pyright reports 0 errors plus the existing__all__warning.route()does not (59.8 s at 32 branches). That is tracked separately in Routing time grows about tenfold per doubling on dense parallel sheets #567.Checklist
mainand the branch is mergeable🤖 Generated with Claude Code