diff --git a/src/client/ClientGameRunner.ts b/src/client/ClientGameRunner.ts index 83c4e5f40..cd56677b4 100644 --- a/src/client/ClientGameRunner.ts +++ b/src/client/ClientGameRunner.ts @@ -187,6 +187,13 @@ async function createClientGame( : undefined; const usesSharedTileState = !!sharedStateBuffer; + console.log("[ClientGameRunner] SAB flags", { + isIsolated, + canUseSharedBuffers, + hasSharedStateFromMap: !!gameMap.sharedStateBuffer, + usesSharedTileState, + }); + if (canUseSharedBuffers) { // Capacity is number of tile updates that can be queued. // This is a compromise between memory usage and backlog tolerance. @@ -697,6 +704,13 @@ export class ClientGameRunner { drainTime, }; + console.log("[ClientGameRunner] mergeGameUpdates SAB", { + tileCount: tileRefs.length, + utilization, + overflow, + drainTime, + }); + for (const ref of tileRefs) { combinedPackedTileUpdates.push(BigInt(ref)); } diff --git a/src/client/graphics/layers/PerformanceOverlay.ts b/src/client/graphics/layers/PerformanceOverlay.ts index 6c1de8cd7..b4a4e54b6 100644 --- a/src/client/graphics/layers/PerformanceOverlay.ts +++ b/src/client/graphics/layers/PerformanceOverlay.ts @@ -531,6 +531,13 @@ export class PerformanceOverlay extends LitElement implements Layer { this.tileUpdatesPerRender = tileUpdatesCount; this.tileUpdatesPeak = Math.max(this.tileUpdatesPeak, tileUpdatesCount); this.totalTilesUpdated += tileUpdatesCount; + + console.log("[PerformanceOverlay] tile metrics", { + tileUpdatesCount, + ringBufferUtilization, + ringBufferOverflows, + ringDrainTime, + }); } if (ringBufferUtilization !== undefined) { diff --git a/src/core/GameRunner.ts b/src/core/GameRunner.ts index 1b43545c4..8908e8927 100644 --- a/src/core/GameRunner.ts +++ b/src/core/GameRunner.ts @@ -186,6 +186,11 @@ export class GameRunner { let packedTileUpdates: BigUint64Array; const tileUpdates = updates[GameUpdateType.Tile]; if (this.tileUpdateSink !== undefined) { + if (tileUpdates.length > 0) { + console.log("[GameRunner] tile updates for tick", this.game.ticks(), { + count: tileUpdates.length, + }); + } for (const u of tileUpdates) { const tileRef = Number(u.update >> 16n) as TileRef; this.tileUpdateSink(tileRef); diff --git a/src/core/game/GameView.ts b/src/core/game/GameView.ts index a6188b532..5800b1764 100644 --- a/src/core/game/GameView.ts +++ b/src/core/game/GameView.ts @@ -496,6 +496,12 @@ export class GameView implements GameMap { flag: nation.flag, } satisfies PlayerCosmetics); } + + console.log("[GameView] constructed", { + usesSharedTileState: this.usesSharedTileState, + width: this._map.width(), + height: this._map.height(), + }); } isOnEdgeOfMap(ref: TileRef): boolean { diff --git a/src/core/game/TerrainMapLoader.ts b/src/core/game/TerrainMapLoader.ts index 2f6757630..3976aa7ef 100644 --- a/src/core/game/TerrainMapLoader.ts +++ b/src/core/game/TerrainMapLoader.ts @@ -69,6 +69,14 @@ export async function loadTerrainMap( ) : undefined); + console.log("[TerrainMapLoader] loadTerrainMap", { + map, + mapSize, + canUseSharedBuffers, + hasSharedStateArg: !!sharedStateBuffer, + createdStateBuffer: !!stateBuffer, + }); + const gameMap = mapSize === GameMapSize.Normal ? await genTerrainFromBin( diff --git a/src/core/worker/Worker.worker.ts b/src/core/worker/Worker.worker.ts index 586f77e66..81e58b12b 100644 --- a/src/core/worker/Worker.worker.ts +++ b/src/core/worker/Worker.worker.ts @@ -78,6 +78,12 @@ ctx.addEventListener("message", async (e: MessageEvent) => { sharedTileRing = null; } + console.log("[Worker.worker] init", { + hasSharedStateBuffer: !!message.sharedStateBuffer, + hasRingHeader: !!message.sharedTileRingHeader, + hasRingData: !!message.sharedTileRingData, + }); + gameRunner = createGameRunner( message.gameStartInfo, message.clientID,