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

c/topic_table: notify ntp delta waiters in batches #24761

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ztlpn
Copy link
Contributor

@ztlpn ztlpn commented Jan 9, 2025

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

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.3.x
  • v24.2.x
  • v24.1.x

Release Notes

  • none

@vbotbuildovich
Copy link
Collaborator

CI test results

test results on build#60552
test_id test_kind job_url test_status passed
rm_stm_tests_rpunit.rm_stm_tests_rpunit unit https://buildkite.com/redpanda/redpanda/builds/60552#01944d67-4352-4009-bdef-0187a88e71ce FLAKY 1/2

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.
Copy link
Contributor

@bashtanov bashtanov left a 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.

Comment on lines +1644 to +1647
auto end = _pending_ntp_deltas.end();
if (end - begin > batch_size) {
end = begin + batch_size;
}
Copy link
Contributor

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) {
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants