From 95946c5b029fd51997cd5870b00a3e20a276ee6e Mon Sep 17 00:00:00 2001 From: Burrowdev Date: Mon, 19 Oct 2026 04:24:33 +0300 Subject: [PATCH 1/2] perf(db): sync sqlite at checkpoints, not after every commit --- lib/accounts.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/accounts.js b/lib/accounts.js index 9a08ea6..9eec638 100644 --- a/lib/accounts.js +++ b/lib/accounts.js @@ -359,8 +359,11 @@ const load = () => { fs.mkdirSync(config.dataDir, {recursive: true}); db = new DatabaseSync(path.join(config.dataDir, "game.sqlite")); // busy_timeout: something else writing to the file for a moment (a tool, - // a copy being made) is waited for, not an error. - db.exec("PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 5000;"); + // a copy being made) is waited for, not an error. synchronous NORMAL: with + // WAL the disk is synced at checkpoints, not after every commit, which + // held the game up on each chat line and save; a crash of the server + // loses nothing, a power cut at most the last moment's writes. + db.exec("PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL; PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 5000;"); db.exec(SCHEMA); for (const row of db.prepare("SELECT * FROM accounts").all()) { const account = normalize({ From 94b8de801e49429be72440a865358f02595cd844 Mon Sep 17 00:00:00 2001 From: Burrowdev Date: Mon, 19 Oct 2026 07:10:05 +0300 Subject: [PATCH 2/2] fix(sfs): let the login burst through the send backlog limit Every custom colour and item def is written at login before the client reads; at 20000 colours and 5000 clothing that is ~4.2 MB, over the 4 MB backlog limit, so every login was cut off right after it succeeded. Co-Authored-By: Claude Opus 5.5 --- lib/sfs.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/sfs.js b/lib/sfs.js index ab37fe9..dd87083 100644 --- a/lib/sfs.js +++ b/lib/sfs.js @@ -18,7 +18,10 @@ const limits = require("./limits.js"); const POLICY = ''; const MAX_MESSAGE = 64 * 1024; const RATE_WINDOW_MS = 10000; -const MAX_BACKLOG = 4 * 1024 * 1024; +// above what login writes in one go before the client reads any of it: every +// custom colour and custom item def (~4.2 MB on 2026-10-19, at the caps of +// 20000 colours and 5000 clothing), which a 4 MB limit cut off for everyone. +const MAX_BACKLOG = 16 * 1024 * 1024; const MAX_ERRORS_PER_WINDOW = 20; // the Create Account screens are done in a few minutes; a guest connection // does not get to stay for as long as it keeps sending something.