From 23e2d884a1835bdb880ca51a14a5de534187e9b3 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 23 Sep 2020 19:44:24 -0400 Subject: [PATCH] use component crossbeam creates, turn off regex in env_logger --- Cargo.toml | 7 ++++--- src/collapse/common.rs | 12 +++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7048dc55..93e9bd5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,14 +23,15 @@ codecov = { repository = "jonhoo/inferno", branch = "master", service = "github" [features] default = ["cli", "multithreaded", "nameattr"] cli = ["structopt", "env_logger"] -multithreaded = ["dashmap", "crossbeam", "num_cpus"] +multithreaded = ["dashmap", "crossbeam-utils", "crossbeam-channel", "num_cpus"] nameattr = ["indexmap"] [dependencies] ahash = "0.3" -crossbeam = { version = "0.7", optional = true } +crossbeam-utils = { version = "0.7", optional = true } +crossbeam-channel = { version = "0.4", optional = true } dashmap = { version = "3", optional = true } -env_logger = { version = "0.7", optional = true } +env_logger = { version = "0.7", default-features = false, optional = true } indexmap = { version = "1.0", optional = true } itoa = "0.4.3" lazy_static = "1.3.0" diff --git a/src/collapse/common.rs b/src/collapse/common.rs index 46d74d43..867bd331 100644 --- a/src/collapse/common.rs +++ b/src/collapse/common.rs @@ -7,8 +7,6 @@ use std::sync::Arc; use ahash::AHashMap; #[cfg(feature = "multithreaded")] -use crossbeam::channel; -#[cfg(feature = "multithreaded")] use dashmap::DashMap; use lazy_static::lazy_static; @@ -199,19 +197,19 @@ pub trait CollapsePrivate: Send + Sized { assert!(nthreads > 1); assert!(occurrences.is_concurrent()); - crossbeam::thread::scope(|scope| { + crossbeam_utils::thread::scope(|scope| { // Channel for sending an error from the worker threads to the main thread // in the event a worker has failed. - let (tx_error, rx_error) = channel::bounded::(1); + let (tx_error, rx_error) = crossbeam_channel::bounded::(1); // Channel for sending input data from the main thread to the worker threads. // We choose `2 * nthreads` as the channel size here in order to limit memory // usage in the case of particularly large input files. - let (tx_input, rx_input) = channel::bounded::>(2 * nthreads); + let (tx_input, rx_input) = crossbeam_channel::bounded::>(2 * nthreads); // Channel for worker threads that have errored to signal to all the other // worker threads that they should stop work immediately and return. - let (tx_stop, rx_stop) = channel::bounded::<()>(nthreads - 1); + let (tx_stop, rx_stop) = crossbeam_channel::bounded::<()>(nthreads - 1); let mut handles = Vec::with_capacity(nthreads); for _ in 0..nthreads { @@ -226,7 +224,7 @@ pub trait CollapsePrivate: Send + Sized { // TODO: https://github.com/crossbeam-rs/crossbeam/issues/404 #[allow(clippy::drop_copy, clippy::zero_ptr)] let handle = scope.spawn(move |_| loop { - channel::select! { + crossbeam_channel::select! { recv(rx_input) -> input => { // Receive input from the main thread. let data = match input {