Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undeterministic blob pull order could cause suboptimal extraction #5832

Open
tonistiigi opened this issue Mar 11, 2025 · 0 comments
Open

Undeterministic blob pull order could cause suboptimal extraction #5832

tonistiigi opened this issue Mar 11, 2025 · 0 comments

Comments

@tonistiigi
Copy link
Member

The lazy image puller that pulls & extracts layers on first access https://github.com/moby/buildkit/blob/v0.20.1/cache/refs.go#L1270-L1311 works with errgroup where pulling blob and unlazying parent are done in parallel, and once both complete, unpack on the blob can run. This allows unpack to start running while some blobs are still being pulled.

When looking at the OTEL traces, it seems that (because of the errgroup contention) the HTTP requests do not go out in deterministic order and never in the actual order of the layers that would be optimal for performance. Because the parallelization of requests is limited per registry, the download attempts for the first layer wait in queue atm while the later layers are being downloaded (assuming image has more layers than parallelization limit).

It seems that in practical cases the order looks more closer to reverse order of the image layers. At least when testing with python image, then the HTTP request for the first layer was always either the last or penultimate to go out. I think even if it is hard to guarantee the most optimal order every time, then this reverse-like order should be avoided.

Not entirely clear what would be the best way to improve this. Adding more sequential logic to pulling blobs reduces the performance of the download phase. Some of it is also completely out of our control, eg. most registries do multiple requests internally (in hub first request goes to docker.io, that usually redirects to cloudflare).

@sipsma

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

No branches or pull requests

1 participant