Fix compilation on macos (#403)
This commit is contained in:
parent
98bb4cc4b6
commit
637314e7f1
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -210,6 +210,7 @@ dependencies = [
|
|||
"av-format",
|
||||
"av-ivf",
|
||||
"av-scenechange",
|
||||
"cfg-if 1.0.0",
|
||||
"chrono",
|
||||
"crossbeam-channel",
|
||||
"crossbeam-utils",
|
||||
|
@ -659,9 +660,9 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4"
|
|||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.13.23"
|
||||
version = "0.13.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a8057932925d3a9d9e4434ea016570d37420ddb1ceed45a174d577f24ed6700"
|
||||
checksum = "845e007a28f1fcac035715988a234e8ec5458fd825b20a20c7dec74237ef341f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
|
@ -813,9 +814,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.12.24+1.3.0"
|
||||
version = "0.12.25+1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c"
|
||||
checksum = "8f68169ef08d6519b2fe133ecc637408d933c0174b23b80bb2f79828966fbaab"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
@ -1734,9 +1735,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
|||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.13.0"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "588b2d10a336da58d877567cd8fb8a14b463e2104910f8132cd054b4b96e29ee"
|
||||
checksum = "52963f91310c08d91cb7bff5786dfc8b79642ab839e188187e92105dbfb9d2c8"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"bytes",
|
||||
|
|
|
@ -172,6 +172,9 @@ pub struct CliOpts {
|
|||
pub workers: usize,
|
||||
|
||||
/// Optionally pin each worker to this many threads
|
||||
///
|
||||
/// This option does nothing on unsupported platforms (currently only
|
||||
/// supported on Linux and Windows)
|
||||
#[structopt(long)]
|
||||
pub set_thread_affinity: Option<usize>,
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ which = "4.1.0"
|
|||
strsim = "0.10.0"
|
||||
crossbeam-channel = "0.5.1"
|
||||
crossbeam-utils = "0.8.5"
|
||||
flexi_logger = "0.19.0"
|
||||
flexi_logger = "0.19.6"
|
||||
textwrap = "0.14.2"
|
||||
path_abs = "0.5.1"
|
||||
av-scenechange = "0.7.2"
|
||||
|
@ -42,6 +42,11 @@ thiserror = "1.0.30"
|
|||
paste = "1.0.5"
|
||||
simdutf8 = "0.1.3"
|
||||
parking_lot = "0.11.2"
|
||||
cfg-if = "1.0.0"
|
||||
|
||||
# TODO: https://github.com/elast0ny/affinity/issues/2
|
||||
# update this when macos support is implemented
|
||||
[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
|
||||
affinity = "0.1.2"
|
||||
|
||||
[dependencies.smallvec]
|
||||
|
|
|
@ -103,22 +103,26 @@ impl<'a> Broker<'a> {
|
|||
}
|
||||
drop(sender);
|
||||
|
||||
if let Some(threads) = set_thread_affinity {
|
||||
let available_threads = num_cpus::get();
|
||||
let requested_threads = threads.saturating_mul(self.project.workers);
|
||||
if requested_threads > available_threads {
|
||||
// extra newline required to actually display warning in terminal
|
||||
// TODO: fix hack and implement correct solution, which is to use a logger that calls `println` on
|
||||
// the progress bar so that it is guaranteed to be displayed properly
|
||||
warn!(
|
||||
"ignoring set_thread_affinity: requested more threads than available ({}/{})\n",
|
||||
requested_threads, available_threads
|
||||
);
|
||||
set_thread_affinity = None;
|
||||
} else if requested_threads == 0 {
|
||||
warn!("ignoring set_thread_affinity: requested 0 threads\n");
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(target_os = "linux", target_os = "windows"))] {
|
||||
if let Some(threads) = set_thread_affinity {
|
||||
let available_threads = num_cpus::get();
|
||||
let requested_threads = threads.saturating_mul(self.project.workers);
|
||||
if requested_threads > available_threads {
|
||||
// extra newline required to actually display warning in terminal
|
||||
// TODO: fix hack and implement correct solution, which is to use a logger that calls `println` on
|
||||
// the progress bar so that it is guaranteed to be displayed properly
|
||||
warn!(
|
||||
"ignoring set_thread_affinity: requested more threads than available ({}/{})\n",
|
||||
requested_threads, available_threads
|
||||
);
|
||||
set_thread_affinity = None;
|
||||
} else if requested_threads == 0 {
|
||||
warn!("ignoring set_thread_affinity: requested 0 threads\n");
|
||||
|
||||
set_thread_affinity = None;
|
||||
set_thread_affinity = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,14 +132,18 @@ impl<'a> Broker<'a> {
|
|||
.map(|(rx, queue, worker_id)| {
|
||||
let tx = tx.clone();
|
||||
s.spawn(move |_| {
|
||||
if let Some(threads) = set_thread_affinity {
|
||||
let mut cpu_set = SmallVec::<[usize; 16]>::new();
|
||||
cpu_set.extend((threads * worker_id..).take(threads));
|
||||
if let Err(e) = affinity::set_thread_affinity(&cpu_set) {
|
||||
warn!(
|
||||
"failed to set thread affinity for worker {}: {}",
|
||||
worker_id, e
|
||||
)
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(target_os = "linux", target_os = "windows"))] {
|
||||
if let Some(threads) = set_thread_affinity {
|
||||
let mut cpu_set = SmallVec::<[usize; 16]>::new();
|
||||
cpu_set.extend((threads * worker_id..).take(threads));
|
||||
if let Err(e) = affinity::set_thread_affinity(&cpu_set) {
|
||||
warn!(
|
||||
"failed to set thread affinity for worker {}: {}",
|
||||
worker_id, e
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue