Files
OpenNest/OpenNest.Engine
ajandClaude Fable 5.2 6067d0c89e perf(bestfit): evaluate pair candidates without rebuilding the parts
PairEvaluator built two parts for every candidate and converted and
chained each one's program twice, about 140 KB of garbage per candidate.
Under the workstation GC that allocation, not the arithmetic, set the
pace.

It now builds the first part once and the second once per rotation, and
applies each candidate's offset to their hull vertices and bounds. The
overlap polygons are flattened straight from the perimeter program's
codes: turned, converted, chained, moved and flattened with the operands
and order of the long way, using the conversion's and Arc's own helpers.
The chain ShapeBuilder finds is recorded once and replayed, which is only
done when every pair of entity ends is clearly together or clearly apart;
otherwise, and for full circles, incremental moves and sub-programs, the
perimeter is built as before.

On 51 drawings from four production nests (68,521 candidates) the
evaluator goes from 5.9 s to 0.93 s and FindCandidates from 7.9 s to
3.3 s; allocation falls from 9.6 GB to 1.6 GB. Results, their order and
the overlap polygons are bit-identical to the previous evaluator, which
the tests keep as a frozen oracle.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 13:26:52 -05:00
..