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 --unified-scheduler-handler-threads #35195

Merged
merged 4 commits into from
Feb 22, 2024

Conversation

ryoqun
Copy link
Member

@ryoqun ryoqun commented Feb 14, 2024

Problem

There's no way to adjust the number of threads via cli for unified scheduler because it's still single-threaded. However, this won't hold eternally. :)

Summary of Changes

Provide such a way in advance for upcoming pr, which makes the unified scheduler multi-threaded with actual scheduler logic.

--help

(note: both output is identical)

$ SOLANA_NO_HIDDEN_CLI_ARGS="" solana-validator --help
...
        --unified-scheduler-handler-threads <COUNT>
            Change the number of the unified scheduler's transaction execution threads dedicated to each block,
            otherwise calculated as cpu_cores/4 [default: 12]
...

$ SOLANA_NO_HIDDEN_CLI_ARGS="" solana-ledger-tool --help
...
        --unified-scheduler-handler-threads <COUNT>
            Change the number of the unified scheduler's transaction execution threads dedicated to each block,
            otherwise calculated as cpu_cores/4 [default: 12]
...

context

extracted from #33070

@ryoqun ryoqun requested a review from apfitzge February 14, 2024 06:53
Comment on lines +93 to +97
let handler_count = handler_count.unwrap_or(1);
// we're hard-coding the number of handler thread to 1, meaning this impl is currently
// single-threaded still.
assert_eq!(handler_count, 1); // replace this with assert!(handler_count >= 1) later

Copy link
Member Author

Choose a reason for hiding this comment

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

so, --unified-scheduler-handler-threads is meaningless for now.

(diff would be a lot clearer if i had more foresight at #34676..)

Comment on lines +852 to +853
Arg::with_name("unified_scheduler_handler_threads")
.long("unified-scheduler-handler-threads")
Copy link
Member Author

@ryoqun ryoqun Feb 14, 2024

Choose a reason for hiding this comment

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

outside unified-scheduler-pool code, i think handler thread count is too verbose and impl-oriented naming. so, I used handler threads intentionally. Also note that there's bunch of --*-threads cli flags in solana-validator as precedents. so, ending at -treads should be no-brainer.

on the other hand, handler is left for technical rigidness, because there's additional thread scScheduler, which are created for each scheduler. and the thread doesn't count towards to unified-scheduler-handler-threads.

Comment on lines +852 to +859
Arg::with_name("unified_scheduler_handler_threads")
.long("unified-scheduler-handler-threads")
.value_name("COUNT")
.takes_value(true)
.validator(|s| is_within_range(s, 1..))
.global(true)
.hidden(hidden_unless_forced())
.help(DefaultSchedulerPool::cli_message()),
Copy link
Member Author

Choose a reason for hiding this comment

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

the actual builder method invocation order and lack of .global(true) are the subtle differences from the solana-validator counterpart. however, this is my best attempt to be consistent within respective surrounding convention (btw, hard to see consistencies in each places; they're already inconsistent, thus this is my arbitrary best effort)...


MESSAGE.get_or_init(|| {
format!(
"Change the number of the unified scheduler's transaction execution threads \
Copy link
Member Author

@ryoqun ryoqun Feb 14, 2024

Choose a reason for hiding this comment

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

while i'm leaving impl jargon (handler) inside the cli flag name, I intentionally avoided to use the word handler in this cli message, instead using the phrase transaction execution threads. That's my habit for achieving both grep-ablity and rephrase-based quick introduction of unfamiliar words (= the handler in the cli flag) for human.

MESSAGE.get_or_init(|| {
format!(
"Change the number of the unified scheduler's transaction execution threads \
dedicated to each block, otherwise calculated as cpu_cores/4 [default: {}]",
Copy link
Member Author

@ryoqun ryoqun Feb 14, 2024

Choose a reason for hiding this comment

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

dedicated to each block has rather important significance here to avoid misunderstanding of this number being the global thread count inside the whole solana-validator process.

also, this whole message is specifically worded to put other calculated as cpu_cores/4 at the end of this message, so that it's lexically close enough to the actual default value.

.long("unified-scheduler-handler-threads")
.value_name("COUNT")
.takes_value(true)
.validator(|s| is_within_range(s, 1..))
Copy link
Member Author

@ryoqun ryoqun Feb 14, 2024

Choose a reason for hiding this comment

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

i thought about introducing some sensible upper bound like 1024, but opted not to do so because this flag doesn't need to be friendly that much and that restriction would hamper some pathological stress testing (again, this isn't strong point, as this is veerry niche & hypothetical use case).

}

pub fn cli_message() -> &'static str {
static MESSAGE: OnceLock<String> = OnceLock::new();
Copy link
Member Author

@ryoqun ryoqun Feb 14, 2024

Choose a reason for hiding this comment

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

back into the very beginnings of this looong unified scheduler journey, OnceLock hasn't been stabilized yet.. ;) ref: #30746 (review)

Copy link

codecov bot commented Feb 14, 2024

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (897adb2) 81.6% compared to head (857e952) 81.6%.
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #35195     +/-   ##
=========================================
- Coverage    81.6%    81.6%   -0.1%     
=========================================
  Files         833      833             
  Lines      224827   224863     +36     
=========================================
+ Hits       183523   183547     +24     
- Misses      41304    41316     +12     

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.

cli arg(s) lgtm - feels a bit odd to introduce a new CLI argument that will cause the code to break if you actually use it, even if it is hidden. I know the impl is coming shortly, so I don't want to block your work.

@ryoqun ryoqun merged commit 024d6ec into solana-labs:master Feb 22, 2024
46 checks passed
jeffwashington pushed a commit to jeffwashington/solana that referenced this pull request Feb 27, 2024
* Add --unified-scheduler-handler-threads

* Adjust value name

* Warn if the flag was ignored

* Tweak message a bit
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