Skip to content

Fetch an image's blobs concurrently when mirroring - #644

Open
simonchrz wants to merge 3 commits into
git-pkgs:mainfrom
simonchrz:mirror-parallel-blobs
Open

simonchrz wants to merge 3 commits into
git-pkgs:mainfrom
simonchrz:mirror-parallel-blobs

Conversation

@simonchrz

@simonchrz simonchrz commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

The image mirror fetched a manifest's config and layer blobs one after another, so a run took as long as all of them together. This fetches up to three at once, the same as a Docker pull does by default.

On a Raspberry Pi, a scheduled run for homeassistant/home-assistant:beta (550 MB in ten blobs) took 27s, with the blobs fetched in strict order. Parallel fetching should bring that close to the time of the largest layer (about 12s).

  • The seen and warnings bookkeeping stays sequential. Only mirrorBlob runs concurrently, and it now returns its size instead of updating the result.
  • When a blob fails, no further blobs start, but those in flight finish instead of being cancelled: a client pull may share their fetch, and they would otherwise be fetched again next run.
  • Blobs are streamed to storage, so memory use does not grow with concurrency.
  • The new test fails on main and passes with -race.

The image mirror fetched the config and layer blobs of a manifest one
after another, so a run took as long as all layers together. It now
fetches up to three at once, as many as a Docker pull does by default.
For a Home Assistant image (550 MB in ten blobs) that would leave
mostly the time of its largest layer.
TestMirrorImageKeepsTagMovedByPullDuringWalk moves a tag while a blob is
served. With blobs fetched concurrently, another blob request reads the
manifest map at the same time, which the race detector caught on
Windows.
errgroup.WithContext cancelled the blobs being fetched as soon as one
failed. A client pull sharing one of those fetches failed with it, and the
next run had to fetch them again. A failure now only stops further blobs
from starting.
@simonchrz

Copy link
Copy Markdown
Contributor Author

Changed in fd16ba1: errgroup.WithContext cancelled the other blob fetches as soon as one failed. A client pull that joined one of those fetches failed with it, and the next run fetched them again. A failure now only stops further blobs from starting. TestMirrorImageBlobFailureKeepsOtherFetches has a blob 404 while another is in flight, and checks that the other one is cached.

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

⌂ Proxy