Skip to content

grpc/load_balancing: Remove unused OneSubchannelPicker. - #2928

Merged
nathanielford merged 6 commits into
masterfrom
refactor/wakeup-picker
Oct 15, 2026
Merged

nathanielford merged 6 commits into
masterfrom
refactor/wakeup-picker

Conversation

@nathanielford

@nathanielford nathanielford commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

OneSubchannelPicker currently exists in both mod.rs and in pick_first.rs. Since it's only used by pick_first, it should only exist private to that LB.

Solution

Remove the unused mod.rs copy of OneSubchannelPicker.

Comment thread grpc/src/client/load_balancing/mod.rs
Comment thread grpc/src/client/load_balancing/mod.rs Outdated
impl Picker for WakeUpPicker {
fn pick(&self, _request: &RequestHeaders) -> PickResult {
if !self.triggered_work.swap(true, Ordering::Relaxed) {
self.work_scheduler.schedule_work(None);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The None here is semantically significant. We can't just assume that. That should be passed in when creating. And we should give this a better name that works in this new context, like OneShotWorkPicker. But honestly, having two separate implementations of this seems fine. There's no need to manually compress the source code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand about the None being semantically significant? It is significant to schedule_work but both pickers are passing it, so I'm not entirely clear what the concern is on that point?

As for the other point, that's valid - I'm happy to rename (but don't particularly have a strong preference as to the name) or drop the consolidation entirely (and rewording the PR to just be about removing redundant OneSubchannelPicker). Preference?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The meaning of the work object is determined by the LB policy. None happens to be what they used, but they might have needed something different and means nothing by itself. We shouldn't be manually compressing the code: seeing places that look the same and combining them. We can however combine things that are semantically the same, and to do that here we have to let the caller provide the None.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah! I see what you mean now. And I agree that means we shouldn't be munging those things together, even if it would behave properly (for now). As a result, I've pulled that change out and just made this about removing the OneSubchannelPicker duplication. I will probably add a variant to pick_first to be explicit about it's idle case, but I can handle that in the PR around it. Thanks!

pub(crate) struct OneSubchannelPicker {
sc: Arc<dyn Subchannel>,
}
pub(crate) struct QueuingPicker;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In Java we have a FixedResultPicker. You provide it the PickResult when constructing and it always returns that thing. You can then use it for queuing, single-subchannel, failing. It has been convenient.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah - as noted this is not actually new, the diff just mangled this horribly for some reason. The QueueingPicker has been in there for a while. A refactor of that might need to be a separate discussion/PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this goes back to the "don't manually compress the code." As something is used once or two places moving it every time that changes. Instead, we have utilities that are likely to be used often. And a FixedResultPicker would be able to take the place of both OneSubchannelPicker and QueuingPicker.

You can add FixedResultPicker now, and use it in place of OneSubchannelPicker. Then in the future we could replace QueuingPicker with FixedResultPicker.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I'll leave that for a future PR - this was largely to remove some review burden elsewhere, and I don't want to complicate matters around that for the moment at the risk of slowing things down. The main issue with OneSubchannelPicker is that the one in mod.rs is not being utilized, so probably shouldn't be there.

@nathanielford nathanielford changed the title grpc/load_balancing: Make WakeUpPicker common. grpc/load_balancing: Make WakeUpPicker common, remove unused OneSubchannelPicker. Oct 14, 2026
@nathanielford nathanielford changed the title grpc/load_balancing: Make WakeUpPicker common, remove unused OneSubchannelPicker. grpc/load_balancing: Remove unused OneSubchannelPicker. Oct 15, 2026
@nathanielford
nathanielford requested a review from ejona86 October 15, 2026 18:37
@nathanielford
nathanielford merged commit 4ad6538 into master Oct 15, 2026
54 checks passed
@nathanielford
nathanielford deleted the refactor/wakeup-picker branch October 15, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants