Repository navigation
remotes/docker: throttle worker chunk buffers - #14311
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The core logic is sound and well tested, but concurrent download lifecycle changes warrant final human review.
0 open findings
What changed in this PR
Caps per-layer parallel-fetch memory using a sliding chunk window.
Changes:
- Gates new chunk downloads on consumption of older chunks.
- Handles cancellation and closes undispatched chunk writers.
- Adds window, cancellation, error, and close-path tests.
| File | Description |
|---|---|
core/remotes/docker/fetcher.go |
Implements the bounded sliding window. |
core/remotes/docker/fetcher_test.go |
Adds coverage for windowing and termination paths. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
With max_concurrent_downloads and concurrent_layer_fetch_buffer set, containerd can use far more memory than intended. The download limiter bounds how many requests run at once. A downloaded chunk stays in memory until the reader consumes it. When the registry is faster than the content store write, chunks accumulate up to the size of the layer. Add a per-layer sliding window of max_workers chunks. Download a new chunk only after the reader has consumed the oldest chunk in the window. A layer then holds at most chunk_size * max_workers of chunk buffers. When the fetch is cancelled, close the writers of chunks that never reached a worker, as a reader would otherwise block on them forever. Pooled buffers and other overhead add to total memory use. Signed-off-by: Maksym Pavlenko <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The concurrent buffer lifecycle and cancellation changes warrant final human validation despite focused test coverage.
0 open findings
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
|
/cherry-pick release/2.4 |
|
@mxpv: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| return err | ||
| } | ||
| for i := range numChunks { | ||
| if i >= parallelism { |
There was a problem hiding this comment.
just quick question, not blocker: so, only first one is slow, the i must wait for first one to close even if rest of them are idle. is it correct?
There was a problem hiding this comment.
the i must wait for first one to close even if rest of them are idle. is it correct?
Chunks has equal size and belong to the same layer here.
I'd imagine what you're describing should be pretty rare?
Do you think of some kind of throttling scenario?
There was a problem hiding this comment.
I just recalled this one - #12811. Not sure it's rare case. We can keep eyes on that. It's trade-off. Your change introduces kind of head-of-line blocking which can avoid memory issue.
|
@mxpv: new pull request created: #14342 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This PR addresses downloaded chunk data accumulating when the reader falls behind.
With
max_concurrent_downloadsandconcurrent_layer_fetch_bufferset, containerd can use far more memory than intended limit (max_concurrent_downloads * concurrent_layer_fetch_buffer).The download limiter bounds how many requests run at once, but downloaded chunk stays in memory until the reader consumes it. When the registry is faster than the content store write, chunks accumulate up to the size of the layer. We observed during node boots, when the daemon pull a lot of large images altogether.
This PR adds a per-layer sliding window, so we don't allocate chunks ahead. We download a new chunk only after the reader has consumed the oldest chunk in the window. A layer then holds at most
chunk_size * max_workersof chunk buffers.