-
Notifications
You must be signed in to change notification settings - Fork 589
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
admin_server/get_partition: Avoid oversized allocation #11824
admin_server/get_partition: Avoid oversized allocation #11824
Conversation
Avoid oversized allocation by: * Collecting summaries into a fragmented_vector * Streaming the vector to an output_stream The overload of `ss::json::json_return_type` that provides an `ss::output_stream` requires a `std::function`, which is required to be copyable, so wrap the `fragmented_vector` in a simple container wrapper that holds the container by `ss::lw_shared_ptr`. Another optimisation is moving rather than copying during accumulation. Fixes redpanda-data#11674 Signed-off-by: Ben Pope <[email protected]>
/cdt |
The oversized allocs in this test run are:
There's another one:
|
On a roll, @BenPope -- thank you! |
@BenPope does this comment mean the PR isn't ready for review, or is the new over sized allocation something you turned into a different ticket to look into? |
No, I'm just noting an oversized alloc iin the test that hasn't got a ticket yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
template<typename C> | ||
class lw_shared_container { | ||
public: | ||
using iterator = C::iterator; | ||
using value_type = C::value_type; | ||
|
||
explicit lw_shared_container(C&& c) | ||
: c_{ss::make_lw_shared<C>(std::move(c))} {} | ||
|
||
iterator begin() const { return c_->begin(); } | ||
iterator end() const { return c_->end(); } | ||
|
||
private: | ||
ss::lw_shared_ptr<C> c_; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should this be in some utility folder somewhere? Could this be useful for other refactoring situations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering that; I haven't seen anything similar anywhere. I expect it will be useful again in this file, but perhaps also pandaproxy/rest. It can be moved later, I guess.
/backport v23.1.x |
Failed to run cherry-pick command. I executed the commands below:
|
Avoid oversized allocation by:
fragmented_vector
ss::output_stream
The overload of
ss::json::json_return_type
that provides anss::output_stream
requires astd::function
, which is required to be copyable, so wrap thefragmented_vector
in a simple container wrapper that holds the container byss::lw_shared_ptr
.Another optimisation is moving rather than copying during accumulation.
Fixes #11674
Backports Required
Release Notes
Improvements