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

Thread manager instantiation in the validator #4603

Merged
merged 5 commits into from
Jan 28, 2025

Conversation

alexpyattaev
Copy link

@alexpyattaev alexpyattaev commented Jan 23, 2025

Problem

Starting the integration of thread manager into agave. This PR is just to make sure thread manager can be instantiated at startup. Separate PRs will be made to add CLI arguments, and to actually patch it in where it is needed.

Summary of Changes

  • Add built-in config to thread manager (in case user does not specify any)
  • Make thread manager start with agave
  • Make sure agave can exit when started from async functions (for tests and test_validator)

@alexpyattaev alexpyattaev force-pushed the tm_validator branch 3 times, most recently from 7dc07f7 to ed1cb50 Compare January 23, 2025 21:46
@alexpyattaev alexpyattaev force-pushed the tm_validator branch 2 times, most recently from 4722843 to faace10 Compare January 23, 2025 22:52
@alexpyattaev alexpyattaev marked this pull request as ready for review January 23, 2025 22:52
max_threads = 8

[rayon_configs.solRetransmit] # runs turbine protocol retransmit logic
max_threads = 4

Choose a reason for hiding this comment

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

I thought current Agave set this to 8

Copy link
Author

Choose a reason for hiding this comment

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

Yes, these are all from optimized config. I have pulled them all from the PR for now and will initially use current values (even though these are "better").

worker_threads = 4

[rayon_configs.solWinInsert]
worker_threads = 2

Choose a reason for hiding this comment

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

I think this one was set to 8 as well


[rayon_configs.solAccounts] # AccountsDb foreground threads
worker_threads = 6

Choose a reason for hiding this comment

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

extra newline?

[tokio_configs.solQuicTpuFwd]
worker_threads = 4

[tokio_configs.solRepairQuic] # this is not used on MNB

Choose a reason for hiding this comment

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

these comments are getting orphaned for sure if/when we turn on QUIC for these protocols 😆

Copy link
Author

Choose a reason for hiding this comment

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

Yes:) But I will re add stuff to the file as I run integration and make sure they are all correct.

thread-manager/src/lib.rs Show resolved Hide resolved
let active_cnt = runtime.running_count.load(Ordering::SeqCst);
match active_cnt {
0 => debug!("Shutting down Native thread pool {name}"),
_ => warn!("Native pool {name} has active threads during shutdown!"),

Choose a reason for hiding this comment

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

might be useful for debug to include number of threads still active

impl ThreadManagerConfig {
/// Returns a valid "built-in" configuration for Agave that is safe to use in most cases.
/// Most operators will likely use this.
pub fn default_for_agave() -> Self {

Choose a reason for hiding this comment

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

could we just make this the default?

Copy link
Author

Choose a reason for hiding this comment

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

No as "default" config should be effectively empty (as it is used by Deserialize). Since this functionessentially parses Toml it would create an infinite loop.

Copy link

@gregcusack gregcusack left a comment

Choose a reason for hiding this comment

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

looks great! Just one recommendation for readability/improving documentation

Comment on lines +8 to +10
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct ThreadManagerConfig {

Choose a reason for hiding this comment

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

would add just a quick comment here about what ThreadManager is, what it does, and why it's needed.

Copy link
Author

Choose a reason for hiding this comment

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

That is already present in https://github.com/alexpyattaev/agave/blob/tm_validator/thread-manager/README.md I did not want to also pollute the code with detailed info that would duplicate the readme. As for the struct you're highlighting I figured ThreadManagerConfig is pretty self-explanatory.

Choose a reason for hiding this comment

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

Hand up! I missed the REAME.

@gregcusack gregcusack self-requested a review January 28, 2025 21:47
Copy link

@gregcusack gregcusack left a comment

Choose a reason for hiding this comment

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

Lgtm!

@alexpyattaev alexpyattaev merged commit e48672c into anza-xyz:master Jan 28, 2025
58 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.

3 participants