Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Searching leader schedule for leader slots is inefficient #8484

Closed
carllin opened this issue Feb 26, 2020 · 2 comments
Closed

Searching leader schedule for leader slots is inefficient #8484

carllin opened this issue Feb 26, 2020 · 2 comments
Labels
enhancement New feature or request stale [bot only] Added to stale content; results in auto-close after a week.
Milestone

Comments

@carllin
Copy link
Contributor

carllin commented Feb 26, 2020

Problem

Follow up to: #8468

In the current implementation here: https://github.com/solana-labs/solana/pull/8468/files#diff-bf2148039ffb77b38df2bbae2f74b418R146,

Once the first leader slot N is found, the last slot is at most N + GRACE_TICKS_FACTOR * MAX_GRACE_SLOTS. This means:

  1. We iterate through at most N + GRACE_TICKS_FACTOR * MAX_GRACE_SLOTS
  2. We only do at most GRACE_TICKS_FACTOR * MAX_GRACE_SLOTS lookups in RocksDb because a validator only does a lookup if the slot belongs to them.

What still sucks: You still have to iterate through N entries in the schedule, granted these iterations are a lot faster because they do not incur a RocksDb lookup.

Proposed Solution

Build a BTreeSet with all the leader schedule slots a validator is scheduled for, which should make "next" queries fast with the btreeset.range function. Purge the set when roots are set.

@stale
Copy link

stale bot commented Apr 19, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Apr 19, 2021
@carllin
Copy link
Contributor Author

carllin commented Apr 20, 2021

Resolved by #15249

@carllin carllin closed this as completed Apr 20, 2021
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request stale [bot only] Added to stale content; results in auto-close after a week.
Projects
None yet
Development

No branches or pull requests

2 participants