From 169e82bb1908a107246bdc265cf8490eb58efc17 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 14 Apr 2026 01:24:03 +0200 Subject: [PATCH] perf: serve /v1/files from SQLite file store (consistent cold cache performance) --- agent/server/src/createRegistryServer.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/agent/server/src/createRegistryServer.ts b/agent/server/src/createRegistryServer.ts index ce56f1e686..ba389a6409 100644 --- a/agent/server/src/createRegistryServer.ts +++ b/agent/server/src/createRegistryServer.ts @@ -334,10 +334,13 @@ async function handleFiles ( res.write(lengthBuf) res.write(jsonBuffer) - // File entries — streamed one at a time + // File entries — read from SQLite when available (consistent + // performance regardless of OS file cache), CAFS fallback. for (const d of digests) { - const cafsPath = getFilePathByModeInCafs(ctx.storeDir, d.digest, d.executable ? 0o755 : 0o644) - const content = readFileSync(cafsPath) + const cached = ctx.fileStore.get(d.digest) + const content = cached + ? cached.content + : readFileSync(getFilePathByModeInCafs(ctx.storeDir, d.digest, d.executable ? 0o755 : 0o644)) const header = Buffer.alloc(69) Buffer.from(d.digest, 'hex').copy(header, 0)