The problem
GET /v2/sandboxes re-reads the runtime settings from SQLite once per row in the response.
infoView (control.ts:203-227) opens with:
const { sandboxDefaults } = readRuntimeSettings(db);
which is a real drizzle SELECT plus view conversion (settings.ts:75-87). The list route (control.ts:649) maps infoView over the whole page, and limit goes up to 1000 (control.ts:87) — so a polled endpoint runs the same query up to 1000 times per request for a value that is per-daemon and identical for every row.
Honest about the magnitude: the repo's own comments measure point reads in microseconds, so the worst case is roughly 1 ms on a 1000-row request, and the route's real cost is dominated by listSandboxes and the per-row JSON.parse. It is genuinely removable duplicate work, but the size of the win is marginal — filing it as a cleanup rather than a performance fix.
Proposed solution
Read once per request and pass it down: const { sandboxDefaults } = readRuntimeSettings(db) in the /v2/sandboxes handler (and the getInfo handler), with infoView taking sandboxDefaults as a parameter. O(page) becomes O(1).
Behaviour is unchanged — the liveness the current code buys ("a console change takes effect on the next request") still holds at per-request granularity.
The problem
GET /v2/sandboxesre-reads the runtime settings from SQLite once per row in the response.infoView(control.ts:203-227) opens with:which is a real drizzle SELECT plus view conversion (
settings.ts:75-87). The list route (control.ts:649) mapsinfoViewover the whole page, andlimitgoes up to 1000 (control.ts:87) — so a polled endpoint runs the same query up to 1000 times per request for a value that is per-daemon and identical for every row.Honest about the magnitude: the repo's own comments measure point reads in microseconds, so the worst case is roughly 1 ms on a 1000-row request, and the route's real cost is dominated by
listSandboxesand the per-rowJSON.parse. It is genuinely removable duplicate work, but the size of the win is marginal — filing it as a cleanup rather than a performance fix.Proposed solution
Read once per request and pass it down:
const { sandboxDefaults } = readRuntimeSettings(db)in the/v2/sandboxeshandler (and thegetInfohandler), withinfoViewtakingsandboxDefaultsas a parameter.O(page)becomesO(1).Behaviour is unchanged — the liveness the current code buys ("a console change takes effect on the next request") still holds at per-request granularity.