From ee3466dff93152204238bd7f83bd456d850bef00 Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Thu, 5 Nov 2026 13:14:00 +0400 Subject: [PATCH] Keep the queued-card check off the per-frame allocation path Writing a fractional alpha onto the overlay record for every paint item boxed a heap number per item per frame. The allocation gate caught it: the generic 60-entry workload went from 2,838 to 12,614 B/frame. The record now keeps only the frame stamp and a pointer to its paint item, and isOverlayEntryQueued multiplies the alphas when it is asked. The gate is back to main's numbers on Node 24. --- src/overlays/worldOverlay.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/overlays/worldOverlay.js b/src/overlays/worldOverlay.js index 16699c548..726e766ee 100644 --- a/src/overlays/worldOverlay.js +++ b/src/overlays/worldOverlay.js @@ -1076,8 +1076,14 @@ export function getOverlayPaintRect(sourceId, entryId) { export function isOverlayEntryQueued(sourceId, entryId) { if (_destroyed) return false; const record = _records.get(entryKey(String(sourceId), String(entryId))); + if (!record || record.queuedStamp !== _frameStamp) return false; + // Same channels as the paint, minus the per-frame keyhole and sonar fades. return ( - !!record && record.queuedStamp === _frameStamp && record.queuedAlpha > 0.001 + record.sourceAlpha * + record.queuedItem.temporalAlpha * + record.distanceAlpha * + record.altitudeAlpha > + 0.001 ); } @@ -1754,7 +1760,7 @@ function getProjectionRecord(entry) { altitudeAlpha: 1, sourceAlpha: 1, queuedStamp: 0, - queuedAlpha: 0, + queuedItem: null, protectedPlacement: null, distanceOptions: {}, altitudeOptions: {}, @@ -2273,13 +2279,10 @@ function addPaintItem(record, placement, temporalAlpha, selected) { item.key = record.key; _paintQueue[_paintCount++] = item; // Read by `isOverlayEntryQueued` while the custom lanes paint, before this - // item publishes its paint rect. Keyhole and sonar fades are left out. + // item publishes its paint rect. Only a stamp and a pointer: storing the + // item's alpha here would box a double per paint item per frame. record.queuedStamp = _frameStamp; - record.queuedAlpha = - record.sourceAlpha * - temporalAlpha * - record.distanceAlpha * - record.altitudeAlpha; + record.queuedItem = item; } function sourceCanPaint(sourceId) {