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

Add BankWithScheduler for upcoming scheduler code #33704

Merged
merged 5 commits into from
Oct 21, 2023

Conversation

ryoqun
Copy link
Member

@ryoqun ryoqun commented Oct 16, 2023

Problem

There's no nice mechanism to accompany a scheduler with a bank for both replaying and banking stage usages in a uniform fashion.

Summary of Changes

Introduce it (BankWithScheduler) before actual introduction of scheduler code...

the code change is rather broad. but i tried to make this pr straightforward as much as possible..

extracted from: #33070

@ryoqun ryoqun requested a review from apfitzge October 16, 2023 07:35
@ryoqun ryoqun force-pushed the bank-with-scheduler branch from cb7a6c4 to 1de3ef6 Compare October 16, 2023 07:48
bank.check_program_modification_slot =
self.root.load(Ordering::Relaxed) < self.highest_slot_at_startup;

let bank = Arc::new(bank);
let prev = self.banks.insert(bank.slot(), bank.clone());
let bank = BankWithScheduler::new_without_scheduler(Arc::new(bank));
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the sole call site of BankWithScheduler constructor, and it is always creating with no scheduler for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we call it above for the insertion of initial forks as well? in new_from_banks

Might just be misunderstanding; this is the only call site where we plan to construct with a scheduler in the future, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is the only call site where we plan to construct with a scheduler (emphasis mine) in the future, right?

yeah. new_from_banks shouldn't have scheduler because they should be frozen, iirc.

@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

Merging #33704 (8758ea9) into master (01f1bf2) will increase coverage by 0.0%.
The diff coverage is 81.3%.

@@           Coverage Diff           @@
##           master   #33704   +/-   ##
=======================================
  Coverage    81.8%    81.8%           
=======================================
  Files         806      807    +1     
  Lines      217428   217492   +64     
=======================================
+ Hits       178058   178122   +64     
  Misses      39370    39370           

@ryoqun ryoqun force-pushed the bank-with-scheduler branch from 1de3ef6 to 5c2e0d4 Compare October 16, 2023 12:49
Copy link
Member Author

Choose a reason for hiding this comment

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

filename is completely misnomer now... ;)

Copy link
Contributor

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

Left a couple of comments, but going to take another pass on this later.

The only thing I didn't make a separate comment on is naming...which I think we discussed before. Still seems weird to have a BankWithScheduler::new_without_scheduler haha, but I'm not sure I can come up with a better name

runtime/src/bank_forks.rs Outdated Show resolved Hide resolved
@ryoqun ryoqun requested a review from apfitzge October 17, 2023 05:23
apfitzge
apfitzge previously approved these changes Oct 19, 2023
Copy link
Contributor

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

Only some very minor comments for clarification & follow-ups.

@@ -82,7 +83,10 @@ impl BankForks {
}

pub fn banks(&self) -> HashMap<Slot, Arc<Bank>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Fine to leave this as a follow-up task, but I don't think we need this interface to be entirely unchanging.
None of the call-sites care that it's specifically an Arc<Bank>, and actually most don't even require ownership of the HashMap itself!

I checked and this compiles just fine:

    pub fn banks(&self) -> &HashMap<Slot, BankWithScheduler> {
        &self.banks
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite as simple for frozen_banks, but that one may also be better off returning an iterator, since most use-cases seem to just be iterating rather than requireing ownership of the map.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we need this interface to be entirely unchanging.

good catch: 0aed626

Not quite as simple for frozen_banks, but that one may also be better off returning an iterator, since most use-cases seem to just be iterating rather than requireing ownership of the map.

yeah. you're right. however, I'll pass to cleaning this...

bank.check_program_modification_slot =
self.root.load(Ordering::Relaxed) < self.highest_slot_at_startup;

let bank = Arc::new(bank);
let prev = self.banks.insert(bank.slot(), bank.clone());
let bank = BankWithScheduler::new_without_scheduler(Arc::new(bank));
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we call it above for the insertion of initial forks as well? in new_from_banks

Might just be misunderstanding; this is the only call site where we plan to construct with a scheduler in the future, right?

runtime/src/bank_forks.rs Show resolved Hide resolved
runtime/src/bank_forks.rs Show resolved Hide resolved
@ryoqun
Copy link
Member Author

ryoqun commented Oct 20, 2023

Only some very minor comments for clarification & follow-ups.

thanks for careful reviews. and sorry about skipping some suggested cleanup. i have to move on...

apfitzge
apfitzge previously approved these changes Oct 21, 2023
Copy link
Contributor

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

CI looks like it had a timeout, if it can pass w/o changes I'm happy to have this code land.

@ryoqun
Copy link
Member Author

ryoqun commented Oct 21, 2023

CI looks like it had a timeout, if it can pass w/o changes I'm happy to have this code land.

sadly, i needed rebase and this 1-line commit (8758ea9) beucase BankForks now needs to impl Debug starting from #33776

i also checked ci was green before the rebase.

@ryoqun ryoqun requested a review from apfitzge October 21, 2023 04:54
@ryoqun ryoqun merged commit 5a96352 into solana-labs:master Oct 21, 2023
17 checks passed
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