@zaisma/game-server 1.40.0 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bench/glass.js +400 -596
- package/bin/like-zaisma.d.ts +15 -0
- package/bin/like-zaisma.js +252 -0
- package/bin/local-play-runner.js +35 -7
- package/bin/local-play.js +19 -1
- package/bin/node-parts.js +32 -3
- package/bin/node.js +76 -0
- package/package.json +1 -1
- package/sdk/zaisma.js +18 -2
- package/src/internal.d.ts +1 -0
- package/src/internal.js +1 -0
- package/src/sandbox-limits.d.ts +32 -0
- package/src/sandbox-limits.js +41 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Zaisma's rooms hold a game server to its limits, and what its logs say when it goes past one. Zaisma's rooms
|
|
3
|
+
* (apps/rooms) and play-locally's runner (bin/like-zaisma.js) share these, so a game server that fails on Zaisma fails
|
|
4
|
+
* the same way on the developer's computer first, with the same line in its logs.
|
|
5
|
+
*/
|
|
6
|
+
/** A real-time room's ticks go to the game server this many to a call, sharing its CPU (30 x 50 ms). */
|
|
7
|
+
export declare const GROUPED_TICK_COUNT = 30;
|
|
8
|
+
/**
|
|
9
|
+
* Calls past their CPU within OVER_BUDGET_WINDOW_MS that stop the game server and end the match, like one that keeps
|
|
10
|
+
* failing (Julius, Nov 13, 2026: the 50 ms a tick has is a budget the room keeps, with Cloudflare's own stop at about
|
|
11
|
+
* 2 s as the backstop).
|
|
12
|
+
*/
|
|
13
|
+
export declare const OVER_BUDGET_CALL_COUNT = 20;
|
|
14
|
+
export declare const OVER_BUDGET_WINDOW_MS = 60000;
|
|
15
|
+
/** Where Cloudflare itself stops a call, whatever CPU it was given. */
|
|
16
|
+
export declare const CALL_STOP_CPU_DURATION_MS = 2000;
|
|
17
|
+
/** How often a real-time room copies its state (never while a copy is under way): a fresh copy of the game server carries on from the last one. */
|
|
18
|
+
export declare const STATE_COPY_INTERVAL_MS = 5000;
|
|
19
|
+
/** Stops in a row (a call stopped, the sandbox failing) after which the room gives up on the game server. */
|
|
20
|
+
export declare const FAILURE_COUNT = 2;
|
|
21
|
+
/** A call stopped for running too long. */
|
|
22
|
+
export declare const CALL_STOPPED_TEXT = "Ran on too long and was stopped, like a loop that never ends";
|
|
23
|
+
/** What the room tells players when it gives up on the game server. */
|
|
24
|
+
export declare const GAME_SERVER_STOPPED_TEXT = "This game's server stopped working.";
|
|
25
|
+
/** Too many calls past their CPU in a minute: the game server stops and the match ends. */
|
|
26
|
+
export declare function overBudgetText(overBudgetCallCount: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* The copy of the game server running the room started again, empty: what it kept in its own variables is gone, and the
|
|
29
|
+
* room carries on from its state. memorySizeBytes is what the copy held when it's known to have gone over its memory,
|
|
30
|
+
* 0 when it went over by an amount nobody measured, and null when the cause isn't known.
|
|
31
|
+
*/
|
|
32
|
+
export declare function copyStartedAgainText(memorySizeBytes: number | null): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GAME_SERVER_LIMITS } from "./room.js";
|
|
2
|
+
/**
|
|
3
|
+
* How Zaisma's rooms hold a game server to its limits, and what its logs say when it goes past one. Zaisma's rooms
|
|
4
|
+
* (apps/rooms) and play-locally's runner (bin/like-zaisma.js) share these, so a game server that fails on Zaisma fails
|
|
5
|
+
* the same way on the developer's computer first, with the same line in its logs.
|
|
6
|
+
*/
|
|
7
|
+
/** A real-time room's ticks go to the game server this many to a call, sharing its CPU (30 x 50 ms). */
|
|
8
|
+
export const GROUPED_TICK_COUNT = 30;
|
|
9
|
+
/**
|
|
10
|
+
* Calls past their CPU within OVER_BUDGET_WINDOW_MS that stop the game server and end the match, like one that keeps
|
|
11
|
+
* failing (Julius, Nov 13, 2026: the 50 ms a tick has is a budget the room keeps, with Cloudflare's own stop at about
|
|
12
|
+
* 2 s as the backstop).
|
|
13
|
+
*/
|
|
14
|
+
export const OVER_BUDGET_CALL_COUNT = 20;
|
|
15
|
+
export const OVER_BUDGET_WINDOW_MS = 60_000;
|
|
16
|
+
/** Where Cloudflare itself stops a call, whatever CPU it was given. */
|
|
17
|
+
export const CALL_STOP_CPU_DURATION_MS = 2000;
|
|
18
|
+
/** How often a real-time room copies its state (never while a copy is under way): a fresh copy of the game server carries on from the last one. */
|
|
19
|
+
export const STATE_COPY_INTERVAL_MS = 5000;
|
|
20
|
+
/** Stops in a row (a call stopped, the sandbox failing) after which the room gives up on the game server. */
|
|
21
|
+
export const FAILURE_COUNT = 2;
|
|
22
|
+
/** A call stopped for running too long. */
|
|
23
|
+
export const CALL_STOPPED_TEXT = "Ran on too long and was stopped, like a loop that never ends";
|
|
24
|
+
/** What the room tells players when it gives up on the game server. */
|
|
25
|
+
export const GAME_SERVER_STOPPED_TEXT = "This game's server stopped working.";
|
|
26
|
+
/** Too many calls past their CPU in a minute: the game server stops and the match ends. */
|
|
27
|
+
export function overBudgetText(overBudgetCallCount) {
|
|
28
|
+
return `Zaisma: ${overBudgetCallCount} calls in the last minute took more than their CPU (${GAME_SERVER_LIMITS.maximumCallCpuDurationMs} ms a tick, shared by the up to ${GROUPED_TICK_COUNT} ticks a call carries), so the game server stopped and the match ended. Keep each tick under ${GAME_SERVER_LIMITS.maximumCallCpuDurationMs} ms: spread big work over several ticks.`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The copy of the game server running the room started again, empty: what it kept in its own variables is gone, and the
|
|
32
|
+
* room carries on from its state. memorySizeBytes is what the copy held when it's known to have gone over its memory,
|
|
33
|
+
* 0 when it went over by an amount nobody measured, and null when the cause isn't known.
|
|
34
|
+
*/
|
|
35
|
+
export function copyStartedAgainText(memorySizeBytes) {
|
|
36
|
+
const carriedOn = `what it kept in its own variables, outside the room's state, is gone. The room carried on from its last state (a real-time room's as of its last copy, taken every ${STATE_COPY_INTERVAL_MS / 1000} seconds), with no onRestored.`;
|
|
37
|
+
if (memorySizeBytes === null)
|
|
38
|
+
return `Zaisma: this copy of the game server started again, so ${carriedOn} A copy starts again when it goes over its ${GAME_SERVER_LIMITS.maximumMemorySizeBytes / 1024 / 1024} MB of memory, after a while unused, and for Zaisma's own updates.`;
|
|
39
|
+
const held = memorySizeBytes > 0 ? ` (it held ${Math.round(memorySizeBytes / 1024 / 1024)} MB)` : "";
|
|
40
|
+
return `Zaisma: the game server went over its ${GAME_SERVER_LIMITS.maximumMemorySizeBytes / 1024 / 1024} MB of memory${held}, data files included, so its copy started again and ${carriedOn} Keep less in memory: load only what a match uses, and drop a room's entry when its match ends.`;
|
|
41
|
+
}
|