perf: serve /v1/files from SQLite file store (consistent cold cache performance)

This commit is contained in:
Zoltan Kochan
2026-04-14 01:24:03 +02:00
parent 4e21041d2c
commit 169e82bb19

View File

@@ -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)