-
Notifications
You must be signed in to change notification settings - Fork 18
chore: bump many_cpus from 1.1.5 to 2.0.0 #241
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| use std::thread::ThreadId; | ||
|
|
||
| use crate::affinity::{MemoryAffinity, PinnedAffinity}; | ||
| use many_cpus::{Processor, ProcessorSet}; | ||
| use many_cpus::Processor; | ||
|
|
||
| /// The number of processors to use for the registry. | ||
| /// | ||
|
|
@@ -62,7 +62,7 @@ | |
| /// If there are more than `u16::MAX` processors or memory regions. | ||
| #[must_use] | ||
| pub fn new(count: &ProcessorCount) -> Self { | ||
| let builder = many_cpus::ProcessorSet::builder(); | ||
| let builder = many_cpus::SystemHardware::current().processors().to_builder(); | ||
|
|
||
| let processors: Vec<_> = match count { | ||
| ProcessorCount::Auto | ProcessorCount::All => builder.take_all(), | ||
|
|
@@ -145,12 +145,21 @@ | |
| let core_index = affinity.processor_index(); | ||
| let processor = &self.processors[core_index]; | ||
|
|
||
| ProcessorSet::from_processor(processor.clone()).pin_current_thread_to(); | ||
| let processor_set = many_cpus::SystemHardware::current() | ||
| .processors() | ||
| .to_builder() | ||
| .filter(|p| p.id() == processor.id()) | ||
| .take_all(); | ||
|
|
||
| self.threads | ||
| .lock() | ||
| .expect("Failed to acquire lock") | ||
| .insert(std::thread::current().id(), affinity); | ||
| // TODO: Handle not found here. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at least log it as warn |
||
| if let Some(ps) = processor_set { | ||
| ps.pin_current_thread_to(); | ||
|
|
||
| self.threads | ||
| .lock() | ||
| .expect("Failed to acquire lock") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This [alternatively, maybe |
||
| .insert(std::thread::current().id(), affinity); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
We should avoid multiple calls to
many_cpus::SystemHardware::current()- the optimal pattern is to acquire the "hardware" instance once and reuse it forever, not touchingcurrent()after that. This creates the opportunity to use a mock/fake platform in tests, so it is important not to callcurrent()except in entrypoint functions.Sidenote: does the possibility of faking the hardware create opportunities for additional testing we want to take advantage of here? We could have some
fn with_hardware(count, &ProcessorCount, hardware: SystemHardware)that one could plug a fake hardware instance into. Might it, for example, catch that missed mutant?