Files
Zoltan Kochan 6c55f72de9 feat(cafs-writer): add fetchBatch, keep writeFiles as default
Adds `fetchBatch(agentUrl, digests, storeDir) → count` to the crate —
a single NAPI call that owns the HTTP POST, gzip decode, parse, and
disk writes for a `/v1/files` batch. Built on `ureq` (sync HTTP) +
`flate2` + the existing rayon write pool.

Benchmarks on test-alot (warm agent, 5 iter, outlier dropped):

  fetchBatch            avg ~20.7s
  writeFiles (buffered) avg ~19.3s     ← the Rust we ship by default
  JS fallback           avg ~19.8s

Sync ureq blocks the worker thread while the response streams, so we
lose the Node event-loop overlap between socket reads and gunzip. On
darwin at least, that ends up slower than letting Node handle HTTP
and handing only the uncompressed payload over NAPI to Rust.

The function is kept in the crate as a springboard for the Linux
io_uring direction — there, a single io_uring can overlap socket
reads and CAFS writes inside the kernel in a way JS can't. The
worker wiring stays on `writeFiles` for now.
2026-04-17 02:00:39 +02:00
..