Skip to content
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

Trim off a few more dependencies #188

Merged
merged 1 commit into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 5 additions & 7 deletions src/collapse/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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::<io::Error>(1);
let (tx_error, rx_error) = crossbeam_channel::bounded::<io::Error>(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::<Vec<u8>>(2 * nthreads);
let (tx_input, rx_input) = crossbeam_channel::bounded::<Vec<u8>>(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 {
Expand All @@ -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 {
Expand Down