-
Notifications
You must be signed in to change notification settings - Fork 6
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
Better multithreading options #84
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest lgtm, nice work
core/src/channel_group/mod.rs
Outdated
/// [this](https://docs.rs/rayon-core/1.11.0/rayon_core/struct.ThreadPoolBuilder.html#method.num_threads) | ||
/// for more information. | ||
#[derive(Clone)] | ||
pub struct ParallelismOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some(0) isn't really a good magic value, that's why we use enums lol.
E.g. "pub enum ThreadCount" with options One, Auto, Manual(u32) or something like that, where Auto just uses the core count
Also It's nice to have constants for these things, because 90% of use cases are just "auto multithreading per channel" or "auto multithreading per channel per key"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. "pub enum ThreadCount" with options One, Auto, Manual(u32) or something like that, where Auto just uses the core count
True that sounds like a better approach. Should also be easier for the user to understand what is going on.
Also It's nice to have constants for these things, because 90% of use cases are just "auto multithreading per channel" or "auto multithreading per channel per key"
You mean make a constant of the enum:
const AUTO_MULTITHREADING: ThreadCount = ThreadCount::Auto
or the struct itself:
const AUTO_MULTITHREADING: ParallelismOptions = ParallelismOptions {
channel: ThreadCount::Auto,
key: ThreadCount::Auto,
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah I meant making it a constant implemented on the struct, you can have const
fields inside impl
blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So like this or a function that returns it?
impl ParallelismOptions {
const AUTO: Self = ParallelismOptions {
channel: ThreadCount::Auto,
key: ThreadCount::Auto,
};
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that, except AUTO_PER_KEY (key and channel) and AUTO_PER_CHANNEL (just channel) with descriptions for each, and an Default implementation that does auto per key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that, except AUTO_PER_KEY (key and channel) and AUTO_PER_CHANNEL (just channel) with descriptions for each, and an Default implementation that does auto per key
Alright yeah that sounds good. Shouldn't default be auto for both though? It was like that before (at least for channel).
Co-authored-by: Leo <[email protected]>
Made the changes, let me know if you meant something else or if there's anything else I should change. |
Anyway just add the constants stuff and I'll check again when I wake up |
core/src/channel_group/config.rs
Outdated
|
||
impl ParallelismOptions { | ||
pub const AUTO_PER_KEY: Self = ParallelismOptions { | ||
channel: ThreadCount::None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be auto here still, because if you're parallelizing voice processing per key you'd probably also want to parallelize event processing too (which must happen per channel)
channel: ThreadCount::None, | |
channel: ThreadCount::Auto, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, will change this and also use this const for Default. Is it ok to merge after this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah
ChannelGroup
andRealtimeSynth
)ChannelGroup