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

Make goto_end_of_slot() take Arc<Bank> #33650

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

ryoqun
Copy link
Member

@ryoqun ryoqun commented Oct 11, 2023

Problem

my scheduler thing needs to introduce rather invasive code changes including the BankWithScheduler wrapping, which touches the quite long-lived goto_end_of_slot() test helper function.

Summary of Changes

In preparation for the scheduler, adjust its argument type in advance to take Arc<Bank>, also clean up odd ::get_mut() and others for consistent call-site coding styles as a bonus.

extracted from: #33070

@ryoqun ryoqun requested a review from apfitzge October 11, 2023 05:24
Comment on lines 5324 to 5327
for _ in 0..MAX_RECENT_BLOCKHASHES + 1 {
goto_end_of_slot(Arc::get_mut(&mut bank).unwrap());
goto_end_of_slot(bank.clone());
bank = Arc::new(new_from_parent(bank));
}
Copy link
Member Author

@ryoqun ryoqun Oct 11, 2023

Choose a reason for hiding this comment

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

i know this for is sickeningly copy-pasted below.. but i forgo fixing them all, because i'm lazy. hope i can be regarded as doing my part of cleaning job here. ;)

};
pub fn goto_end_of_slot(bank: &Bank) {
pub fn goto_end_of_slot(bank: Arc<Bank>) {
Copy link
Member Author

@ryoqun ryoqun Oct 11, 2023

Choose a reason for hiding this comment

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

yes, taking ownership of Arc<Bank> is intentional for upcoming changes. strictly speaking, implied cloning isn't needed, however i leaned towards coding simplicity over perfection.

after all, this isn't part of hot path, rather a tiny and aged test helper function... who cares for additional clones for it? ;)

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

Merging #33650 (067ce37) into master (2f090a5) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##           master   #33650   +/-   ##
=======================================
  Coverage    81.8%    81.8%           
=======================================
  Files         806      806           
  Lines      217477   217477           
=======================================
+ Hits       177999   178019   +20     
+ Misses      39478    39458   -20     

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.

Definitely like all the clean up of unneccessary get_muts.

It basically seems in the upcoming changes of #33070, that register_tick (maybe freeze?) has changed impls and within the wrapping BankWithScheduler. This requires passing a scheduler (if one exists), so we will require this function to create a BankWithScheduler internally, which requires ownership.

There's probably some trickery we could do with Cow to get this so we can avoid the additional cloning...but it's probably not worth the effort for avoiding the clone in a fn only used in testing contexts.

@ryoqun ryoqun merged commit 53925b6 into solana-labs:master Oct 13, 2023
16 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