Skip to content

Bound HTTP fetcher memory use under load - #74

Closed
tomgr wants to merge 1 commit into
buildbarn:mainfrom
tomgr:tom/bound-memory-consumption
Closed

Bound HTTP fetcher memory use under load#74
tomgr wants to merge 1 commit into
buildbarn:mainfrom
tomgr:tom/bound-memory-consumption

Conversation

@tomgr

@tomgr tomgr commented May 29, 2026

Copy link
Copy Markdown
Contributor

The HTTP fetcher read each download fully into memory (io.ReadAll) before storing it in the CAS, so large numbers of parallel fetches could cause OOMs.

Two changes address this:

  • When the blob's digest is known up front (a checksum.sri using the request's digest function, plus a Content-Length), the response is streamed straight to the CAS without being buffered at all.
  • Otherwise the body has to be read to compute the digest. This is still buffered in memory by default, but the new download_directory_path option buffers it in a temporary file on disk instead.

This was written with Claude but I've carefully reviewed it all and tested it end to end locally.

The HTTP fetcher read each download fully into memory (io.ReadAll)
before storing it in the CAS, so large numbers of parallel fetches could
cause OOMs.

Two changes address this:
- When the blob's digest is known up front (a checksum.sri using the
  request's digest function, plus a Content-Length), the response is
  streamed straight to the CAS without being buffered at all.
- Otherwise the body has to be read to compute the digest. This is
  still buffered in memory by default, but the new
  download_directory_path option buffers it in a temporary file on disk
  instead.
@tomgr
tomgr force-pushed the tom/bound-memory-consumption branch from 5762212 to 0b54002 Compare June 11, 2026 10:04
@tomgr

tomgr commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #75

@tomgr tomgr closed this Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant