-
Notifications
You must be signed in to change notification settings - Fork 595
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
c/topic_table: notify ntp delta waiters in batches #24761
base: dev
Are you sure you want to change the base?
Conversation
CI test resultstest results on build#60552
|
When installing a controller snapshot or creating a topic with many partitions, the number of pending deltas can grow quite large. Notify waiters in batches to avoid stalls. This should also fix the problem with controller_backend notification handler that will spawn a lot of ready tasks if the task quota is exceeded.
e98b5d3
to
6263550
Compare
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 took a quick glance on the subscribers, it doesn't look like any of them rely on notifications being consistent with the current state. See comments for some concerns/suggestions regarding iteration.
auto end = _pending_ntp_deltas.end(); | ||
if (end - begin > batch_size) { | ||
end = begin + batch_size; | ||
} |
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.
Have you tried auto end = std::min(begin + batch_size, _pending_ntp_deltas.end())
? According to the iterator category tag It should just work.
_pending_ntp_deltas.cbegin(), _pending_ntp_deltas.cend()}; | ||
if (!changes.empty()) { | ||
const ssize_t batch_size = 128; | ||
for (size_t i = 0; i < _pending_ntp_deltas.size(); i += batch_size) { |
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. Have you checked whether it's okay to increment this iterator past the end? From what I can see, it's down to the iterator implementation, so it's not guaranteed by the iterator traits. Currently iterator position is stored as an index, so it looks safe. But if we change it to e.g. a pair of chunk_id and pos_in_chunk, this code may become invalid. WDYT?
When installing a controller snapshot or creating a topic with many partitions, the number of pending deltas can grow quite large. Notify waiters in batches to avoid stalls. This should also fix the problem with controller_backend notification handler that will spawn a lot of ready tasks if the task quota is exceeded.
Backports Required
Release Notes