Skip to content

Commit

Permalink
Switch to newer hwlocality to remove some unnecessary low-level dep…
Browse files Browse the repository at this point in the history
…epdencies
  • Loading branch information
nazar-pc committed Jan 19, 2024
1 parent 46cb28f commit 20b167e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
9 changes: 3 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ inherits = "release"
lto = "fat"

[patch.crates-io]
# TODO: Switch to release once v1.0.0-alpha.2 or newer is out
hwlocality = { git = "https://github.com/HadrienG2/hwlocality", rev = "0f248573bcad584960fe20293c826203a265b833" }
# TODO: Switch to stable release once https://github.com/paritytech/substrate-bip39/pull/20 is published
substrate-bip39 = { git = "https://github.com/paritytech/substrate-bip39", rev = "03f02a7225d9bc5add92b7657790ee1ac8ab90a4" }

Expand Down
6 changes: 0 additions & 6 deletions crates/subspace-farmer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
ulid = { version = "1.0.0", features = ["serde"] }
zeroize = "1.7.0"

[target.'cfg(not(windows))'.dependencies]
libc = "0.2.152"

[target.'cfg(windows)'.dependencies]
windows-sys = "0.52.0"

[features]
default = ["numa"]
numa = ["dep:hwlocality"]
8 changes: 2 additions & 6 deletions crates/subspace-farmer/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,9 @@ impl CpuCoreSet {
if let Some(topology) = &self.topology {
use hwlocality::cpu::binding::CpuBindingFlags;
use hwlocality::cpu::cpuset::CpuSet;
use hwlocality::current_thread_id;
use hwlocality::ffi::PositiveInt;

#[cfg(not(windows))]
let thread_id = unsafe { libc::pthread_self() };
#[cfg(windows)]
let thread_id = unsafe { windows_sys::Win32::System::Threading::GetCurrentThread() };

// load the cpuset for the given core index.
let cpu_cores = CpuSet::from_iter(
self.cores
Expand All @@ -180,7 +176,7 @@ impl CpuCoreSet {
);

if let Err(error) =
topology.bind_thread_cpu(thread_id, &cpu_cores, CpuBindingFlags::empty())
topology.bind_thread_cpu(current_thread_id(), &cpu_cores, CpuBindingFlags::empty())
{
warn!(%error, ?cpu_cores, "Failed to pin thread to CPU cores")
}
Expand Down

0 comments on commit 20b167e

Please sign in to comment.