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

Limit leader schedule search space #8468

Merged
merged 3 commits into from
Feb 26, 2020

Conversation

carllin
Copy link
Contributor

@carllin carllin commented Feb 26, 2020

Problem

The leader schedule cache next_leader_slot looks for a range of consecutive slots for which a given validator is the leader. If that range is big, potentially multiple epochs if there is only one leader, this search can take a lot of time, since each hit also incurs a lookup in Rocks.

Summary of Changes

Once the first leader slot N is found, limit the last slot to 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. @pgarg66 Maybe we should cache these lookups so the validator doesn't have to start from the beginning every time.
Fixes #8445

@mvines
Copy link
Contributor

mvines commented Feb 26, 2020

Patch looks good in concept, CI seems to hate it though :)
tenor

Totally file a new issue for "what still sucks" too.

@codecov
Copy link

codecov bot commented Feb 26, 2020

Codecov Report

Merging #8468 into master will decrease coverage by 0.0%.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           master   #8468     +/-   ##
========================================
- Coverage    80.3%   80.3%   -0.1%     
========================================
  Files         256     256             
  Lines       56468   56478     +10     
========================================
+ Hits        45351   45354      +3     
- Misses      11117   11124      +7     

@carllin carllin marked this pull request as ready for review February 26, 2020 21:27
Copy link
Contributor

@mvines mvines left a comment

Choose a reason for hiding this comment

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

thanks! Once this hits 0.23, I'll start up an SLP dev cluster and ensure we're 🏎 again

@carllin
Copy link
Contributor Author

carllin commented Feb 26, 2020

@mvines fixed CI, issue is here: #8484

@carllin carllin merged commit 7a2bf7e into solana-labs:master Feb 26, 2020
mergify bot pushed a commit that referenced this pull request Feb 26, 2020
* Limit leader schedule search space

* Fix and add test

* Rename

(cherry picked from commit 7a2bf7e)
mergify bot pushed a commit that referenced this pull request Feb 26, 2020
* Limit leader schedule search space

* Fix and add test

* Rename

(cherry picked from commit 7a2bf7e)
solana-grimes pushed a commit that referenced this pull request Feb 26, 2020
solana-grimes pushed a commit that referenced this pull request Feb 27, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PoH on SLP2 is going very slowly
2 participants