Cache serving pipeline fleet to eliminate per-tick rebuilds and reduce GC pressure

Fleet template is now rebuilt only when deploymentVersion changes (~68 times per
28,800-tick run instead of every tick). Reuses module-level Maps, arrays, and
utilization objects instead of allocating new ones each tick. Replaces 4x
Object.values().reduce() with single-pass aggregation and sorts fleet in-place.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 19:51:13 -04:00
parent bbb69a315c
commit 57a81be769
7 changed files with 190 additions and 99 deletions
+2
View File
@@ -1085,6 +1085,7 @@ export const useGameStore = create<Store>()(
productLines: s.models.productLines.map(pl => ({
...pl, modelId, isActive: true,
})),
deploymentVersion: s.models.deploymentVersion + 1,
},
market: {
...s.market,
@@ -1104,6 +1105,7 @@ export const useGameStore = create<Store>()(
? { ...f, variants: f.variants.map(v => v.id === variantId ? { ...v, isDeployed: true } : v) }
: f,
),
deploymentVersion: s.models.deploymentVersion + 1,
},
}));
get().addNotification({ title: 'Variant Deployed', message: 'Variant is now live.', type: 'success', tick: get().meta.tickCount });