Skip to content

Commit 3423cc5

Browse files
only21milclaude
andcommitted
test(server): assert the 64 MiB page-cache value directly
The setup test now asserts -65536, as the busy_timeout test asserts 5000, so it fails on main with "expected -2000 to equal -65536" and the constant no longer needs to be exported. SQLite fills the cache only as pages are read, so a process holds at most the pages it has read, up to the database's size or 64 MiB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8a6dd21 commit 3423cc5

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎apps/server/src/persistence/Sqlite.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as Effect from "effect/Effect";
1010
import * as Layer from "effect/Layer";
1111
import * as SqlClient from "effect/sql/SqlClient";
1212

13-
import { PAGE_CACHE_SIZE_KIB, WAL_SIZE_LIMIT_BYTES } from "./Sqlite.ts";
13+
import { WAL_SIZE_LIMIT_BYTES } from "./Sqlite.ts";
1414
import * as SqlitePersistence from "./Sqlite.ts";
1515

1616
const lockHolderSource = `
@@ -96,6 +96,6 @@ it.effect("applies the page cache bound in the shared persistence setup", () =>
9696
Effect.gen(function* () {
9797
const sql = yield* SqlClient.SqlClient;
9898
const rows = yield* sql<{ readonly cache_size: number }>`PRAGMA cache_size`;
99-
assert.equal(rows[0]?.cache_size, -PAGE_CACHE_SIZE_KIB);
99+
assert.equal(rows[0]?.cache_size, -65536);
100100
}).pipe(Effect.provide(SqlitePersistence.layerMemory)),
101101
);

‎apps/server/src/persistence/Sqlite.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import * as ServerConfig from "../config.ts";
1212
// Size the -wal file is cut back to on the first commit after a WAL reset.
1313
export const WAL_SIZE_LIMIT_BYTES = 32 * 1024 * 1024;
1414

15-
// Upper bound on the connection's page cache. At SQLite's 2 MiB default, every
16-
// query on a large database re-reads its b-tree pages from the OS. The cache
17-
// only grows as pages are read, so a small database never reaches the bound.
18-
export const PAGE_CACHE_SIZE_KIB = 64 * 1024;
15+
// Page-cache budget for the connection, in KiB. SQLite's 2,000 KiB default is
16+
// smaller than a large database's hot pages, so those get read from the OS
17+
// again. The cache fills only as pages are read.
18+
const PAGE_CACHE_SIZE_KIB = 64 * 1024;
1919

2020
const layerSetup = Layer.effectDiscard(
2121
Effect.gen(function* () {

0 commit comments

Comments
 (0)