Files
OpenNest/OpenNest.Engine
ajandClaude Opus 5.5 b97929a53d perf(planner): skip far parts on large plates without changing the plan
The 5k-washers corpus plate planned in about 90 s alone and timed out at the
corpus's 120 s limit whenever anything else ran, making the corpus fragile.
Profiling showed nearly all of it was linear scans over every part, repeated
per candidate: each lead check walked all 5,742 materials (and first re-tested
that all were complete), each rapid walked every completed contour, each
expansion rebuilt a HashSet of every cut part, each checker copy regrew its
obstacle list, and the nested-part search tested all 33 million part pairs.

A uniform grid over extents (ExtentGrid) now leaves out only parts whose
extents lie beyond the margin the existing skip tests use, and the rest are
visited in their original order, so every check returns exactly what the full
scan returned (same findings, same first obstacle, same budget charges):
- LeadPathValidator visits only materials not clear of the lead's queries or
  its midpoint's row, through a shared LeadMaterialSet built once per walk and
  replay; ContourEntryFeasibility reuses that set instead of copying it per part.
- ReleasedContourState keeps a read-only obstacle prefix with a grid, shared by
  copies, so copies stay cheap and rapids test only nearby contours.
- The search keeps one ordinal flag array per order instead of a HashSet per call.
- CuttingDependencyGraph tests each part only against hosts whose bounds can hold it.

Plate 1 alone: 93.3 s -> 12.3 s (capture 2.7 -> 1.2 s, plan 90.6 -> 11.1 s),
with the identical plan digest and 86,245 expansions; plate 2 also plans
identically. The problem-nest corpus (part-order,entries) gives every plate the
same outcome and expansion count as master, and the Collision kernel and every
tolerance are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 12:58:28 -05:00
..