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/backend: shard_table to be able to notify subscribers #19623

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

bashtanov
Copy link
Contributor

@bashtanov bashtanov commented Jun 11, 2024

Make shard_table able to notify subscribers. Needed for cross-cluster migrations: as partitions move across shards, shard 0 on each node will re-dispatch partition operations to new shards.

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.1.x
  • v23.3.x
  • v23.2.x

Release Notes

  • none

@bashtanov
Copy link
Contributor Author

/dt

@bashtanov bashtanov force-pushed the shard_table_notifications branch from 843b0b6 to fd67174 Compare June 14, 2024 16:39
@bashtanov
Copy link
Contributor Author

/dt

@bashtanov bashtanov marked this pull request as ready for review June 14, 2024 19:47
@bashtanov
Copy link
Contributor Author

test failure due to #14898

@bashtanov bashtanov force-pushed the shard_table_notifications branch from fd67174 to c943a09 Compare June 18, 2024 14:18
@bashtanov bashtanov requested a review from bharathv June 18, 2024 14:19
@bashtanov bashtanov merged commit 89a57f9 into redpanda-data:dev Jun 19, 2024
18 checks passed
raft::group_id g,
std::optional<ss::shard_id> shard)>;

notification_id_type register_notification(change_cb_t&& cb) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to take r-value reference here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can name a couple of reasons to use r-value reference here:

  1. Hinting move semantics to the caller without making them look into the type definition. Might seem useless here, as how do they know the callback signature, but what if they already have the callback value and are making an attempt to reuse it they will probably realise it won't work a bit earlier.
  2. Optimizing out actual moves https://godbolt.org/z/qbcManb57. They are probably cheap but not zero-cost.

Any reasons to pass by value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the primary reason is that (1) it's already non-copyable so you have to move it--no benefit in semantics and (2) it's not in a hot path, right? so copying 40 bytes during registration is nothing. anyway, nothing wrong with using && but it's nice to default to value semantics where possible. no need to change or anything.

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