perf(engine): key fill caches by source drawing so they hit across trials

Every DefaultPlateFiller.Fill makes a fresh canonical copy of the drawing,
and BestFitCache/FillResultCache keyed by drawing reference, so fills never
shared results and the static caches grew without bound.

CanonicalFrame now records which drawing each canonical copy came from.
Both caches key weakly on that source drawing, so every canonical copy
shares one entry and released drawings can be collected. An entry is
dropped when the drawing's Program instance or canonical angle changes.
Best-fit candidates are computed once per (drawing, spacing) through
BestFitFinder.FindCandidates and filtered per plate size with the same
filter FindBestFits uses. FillResultCache keeps canonical and
non-canonical callers apart.

Adds Debug-only PerfCounters for best-fit runs, offset perimeter builds
and Part.Intersects calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
aj
2026-09-23 14:29:43 -04:00
co-authored by Claude Opus 5.5
parent dc9e83ef17
commit 1c363504f5
8 changed files with 525 additions and 233 deletions
+1
View File
@@ -234,6 +234,7 @@ namespace OpenNest
public bool Intersects(Part part, out List<Vector> pts)
{
PerfCounters.CountPartIntersects();
pts = new List<Vector>();
var entities1 = ConvertProgram