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

DefaultLeaderElector::elect_leader binary search #16

Closed
matteojug opened this issue Sep 26, 2024 · 1 comment · Fixed by #18
Closed

DefaultLeaderElector::elect_leader binary search #16

matteojug opened this issue Sep 26, 2024 · 1 comment · Fixed by #18

Comments

@matteojug
Copy link

In DefaultLeaderElector::elect_leader, the binary_search_by is not really helping since we are constructing the cumulative_weights array each time: either we build it once (and then use the bin search, but note that there are other places where we still do a linear scan of the weights), or we can just find the matching index in the for loop above (~leader.rs:139).

@NikitaMasych
Copy link
Member

Yep, thank you. I modified election to deduce party index on the go of prefix sums; won't do caching of cumulative_weights since design of the LeaderElector shall not care about Party's state.

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 a pull request may close this issue.

2 participants