ct/l0: Share, don't copy, downloaded object when caching#29058
Merged
dotnwat merged 1 commit intoredpanda-data:devfrom Jan 6, 2026
Merged
ct/l0: Share, don't copy, downloaded object when caching#29058dotnwat merged 1 commit intoredpanda-data:devfrom
dotnwat merged 1 commit intoredpanda-data:devfrom
Conversation
Use iobuf::share not iobuf::copy to obtain an iobuf to read into the cloud storage cache. This eliminates an extra copy of a fairly hefty (~4MiB usually) buffer, reducing peak memory usage of the L0 fetch. Very minor: I moved the creation of the input stream so it happens after we obtain the space reservation for the object.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes memory usage in the L0 cloud storage fetch path by using iobuf::share() instead of iobuf::copy() when caching downloaded objects. This eliminates an unnecessary copy of the ~4MiB buffer, reducing peak memory consumption during L0 fetches.
Key changes:
- Replaced
iobuf::copy()withiobuf::share()to avoid duplicating the downloaded payload buffer - Moved input stream creation to after space reservation acquisition
dotnwat
reviewed
Jan 2, 2026
| if (sr_guard.has_value()) { | ||
| // TODO: use proper priority class | ||
| probe->num_cache_writes++; | ||
| auto buf_str = make_iobuf_input_stream(payload.share()); |
Member
There was a problem hiding this comment.
it looks like you could make_iobuf_input_stream(std::move(payload)) which I think would be preferrable?
Contributor
Author
There was a problem hiding this comment.
We return std::move(payload) from this function so we can't move out of it here.
dotnwat
approved these changes
Jan 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use iobuf::share not iobuf::copy to obtain an iobuf to read into the cloud storage cache. This eliminates an extra copy of a fairly hefty (~4MiB usually) buffer, reducing peak memory usage of the L0 fetch.
Very minor: I moved the creation of the input stream so it happens after we obtain the space reservation for the object.
Backports Required
Release Notes