MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resolveWalValveMb

Function resolveWalValveMb

src/db/wal-valve.ts:64–78  ·  view source on GitHub ↗
(envVal: string | undefined, dbSizeBytes?: number)

Source from the content-addressed store, hash-verified

62 * override; non-numeric / non-positive values fall back to the default.
63 */
64export function resolveWalValveMb(envVal: string | undefined, dbSizeBytes?: number): number {
65 if (envVal !== undefined && envVal !== '') {
66 const n = Number(envVal);
67 if (Number.isFinite(n) && n > 0) return Math.floor(n);
68 }
69 // Scale with the project when the caller knows the DB size: every fold
70 // re-writes hot B-tree pages into the main file (the #1231 pathology in
71 // bounded form — 111s of a kernel-scale batch loop at the flat 256MB cap,
72 // §7a.2), so a big project affords a proportionally bigger transient WAL
73 // (~dbSize/4 soft ⇒ file cap ≈ dbSize) in exchange for ~4× fewer folds.
74 if (dbSizeBytes !== undefined && dbSizeBytes > 0) {
75 return Math.min(2048, Math.max(DEFAULT_WAL_VALVE_MB, Math.floor(dbSizeBytes / 4 / (1024 * 1024))));
76 }
77 return DEFAULT_WAL_VALVE_MB;
78}
79
80export class WalCheckpointValve {
81 private timer: ReturnType<typeof setInterval> | null = null;

Callers 4

indexAllMethod · 0.90
syncMethod · 0.90
constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected