1
0
Fork 0
polaris-task-force/src/collections/game
Z8MB1E a0f767cc13 perf: cut queries per render and refreshes per realtime event
Under 10-12 concurrent users the app queued behind itself: every SSE
game-event/profile-update made each client run router.refresh(), i.e. a
full layout + page render at ~15-25 queries, and a mission completion
emitted one XP event per attendee row. Measured against production, no
single query is slow and the DB is small, so this targets render count
and per-render query count instead of indexes.

Fewer renders per event:
- GameTickRealtime: 250ms coalescing window -> 1s, hidden tabs skip the
  render and refresh once when shown again.
- Delete OperationsRealtimeRefresher (5 routes) and the duplicate
  useGameTick refreshers in ProductionPanel/SlotsPanel; the global
  subscriber already refreshes those routes.
- Presence heartbeats no longer broadcast (was O(N^2) per channel every
  15s for a lastSeen no surface renders).
- NavCore links opt out of prefetch: the layout is force-dynamic with no
  loading.tsx, so ~35 prefetched links per tab were 35 server renders.

Fewer queries per render:
- Qualification flags go through one cached, single-flight profile read
  instead of one query per auth check; invalidated on profile writes.
- Dedupe DIVISION_ADMIN_QUALIFICATIONS (5 identical lookups -> 1).
- Anchor the permission cache on globalThis so route bundles share it.
- Minigame registry: real TTL cache plus invalidation on write.
- New cachedConfig TTL cache for the shims/game-rules globals, with
  invalidation hooks; bank-account existence check stops hydrating.
- pg pool max 10 -> 20 (node-postgres default throttled concurrent
  renders).

Hot-path per-item work:
- Contribution grant sweep: one status write per batch, one bucket write
  and one name lookup per user, one existence query per source
  collection instead of ~5 queries per entry.
- Notifications bell: coalesced refetch, hidden-tab skip; mark-all-read
  filters by the actor instead of scanning 100 foreign unread rows.
- Polling loops (shipments, ledger, mission reminders, chip bank) pause
  while the tab is hidden.
2026-11-22 22:39:10 -05:00
..
auraFields.ts feat(base): production, modules, adjacency auras, compounds, and crew speed 2026-09-20 02:43:23 -04:00
GameEventLogs.ts feat(map-objectives): superuser-authored strategic objectives on mission maps 2026-10-27 02:12:31 -04:00
GameHardResources.ts feat(rbac): migrate collection access controls to RBAC permissions 2026-08-19 19:47:51 -04:00
GameNpcs.ts feat(npc): add weighted activity, level, and dialogue conversations 2026-10-05 12:51:59 -04:00
GameRules.ts perf: cut queries per render and refreshes per realtime event 2026-11-22 22:39:10 -05:00
GameStructures.ts feat(lockers): seed and unlimited-stock sync for limited arsenal 2026-11-20 19:52:15 -05:00
GameVehicles.ts feat(garage): add vehicle bay schema fields, geometry helpers, and backfill 2026-10-13 16:02:58 -04:00
LaborClassifications.ts feat(base): production, modules, adjacency auras, compounds, and crew speed 2026-09-20 02:43:23 -04:00
MinigameRules.ts feat(minigames): add period, entry, achievement and registry schema 2026-10-11 17:06:52 -04:00
moduleFields.ts feat(interior): upgrade completion, tech/labor gates, and module bonuses 2026-10-20 15:44:36 -04:00
NpcDialogues.ts feat(npc-dialogue): AI-assisted conversation drafting behind the review gate 2026-11-12 12:26:35 -05:00
NpcDialogueStates.ts feat(npc-dialogue): back NEW badges with server-side read markers 2026-10-14 15:35:47 -04:00
NpcStaffing.ts feat(base): add npc staffing and labor classification collections 2026-09-06 01:24:08 -04:00
PlayerFlags.ts feat(event-log): configurable per-event visibility with permission gates 2026-10-06 23:31:30 -04:00
productionFields.ts feat(base): production, modules, adjacency auras, compounds, and crew speed 2026-09-20 02:43:23 -04:00
ReinforcementPools.ts feat(reinforcement-pools): store per-pool balances and sync to the game bridge 2026-10-07 00:28:42 -04:00
researchFields.ts feat(tech): member-facing tech research system and tech tree 2026-10-19 17:28:26 -04:00
staffingFields.ts feat(base): add npc staffing and labor classification collections 2026-09-06 01:24:08 -04:00