mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-30 23:40:41 +00:00
Size SAB ring buffer by world tile count
This commit is contained in:
@@ -190,10 +190,9 @@ async function createClientGame(
|
|||||||
const usesSharedTileState = !!sharedStateBuffer;
|
const usesSharedTileState = !!sharedStateBuffer;
|
||||||
|
|
||||||
if (canUseSharedBuffers) {
|
if (canUseSharedBuffers) {
|
||||||
// Capacity is number of tile updates that can be queued.
|
|
||||||
// This is a compromise between memory usage and backlog tolerance.
|
|
||||||
const TILE_RING_CAPACITY = 262144;
|
|
||||||
const numTiles = gameMap.gameMap.width() * gameMap.gameMap.height();
|
const numTiles = gameMap.gameMap.width() * gameMap.gameMap.height();
|
||||||
|
// Ring capacity scales with world size: at most one entry per tile.
|
||||||
|
const TILE_RING_CAPACITY = numTiles;
|
||||||
sharedTileRingBuffers = createSharedTileRingBuffers(
|
sharedTileRingBuffers = createSharedTileRingBuffers(
|
||||||
TILE_RING_CAPACITY,
|
TILE_RING_CAPACITY,
|
||||||
numTiles,
|
numTiles,
|
||||||
@@ -701,8 +700,8 @@ export class ClientGameRunner {
|
|||||||
uniqueTiles.add(ref);
|
uniqueTiles.add(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate ring buffer utilization and overflow
|
// Calculate ring buffer utilization and overflow using dynamic capacity
|
||||||
const TILE_RING_CAPACITY = 262144;
|
const TILE_RING_CAPACITY = this.tileRingViews.capacity;
|
||||||
const utilization = (uniqueTiles.size / TILE_RING_CAPACITY) * 100;
|
const utilization = (uniqueTiles.size / TILE_RING_CAPACITY) * 100;
|
||||||
const overflow = Atomics.load(
|
const overflow = Atomics.load(
|
||||||
this.tileRingViews.header,
|
this.tileRingViews.header,
|
||||||
|
|||||||
Reference in New Issue
Block a user