diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2021-12-28 12:11:32 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2021-12-28 12:11:32 -0500 |
commit | e7f192f1c6f16144c921bd5c33544750d2494f15 (patch) | |
tree | dfea46b21d65fb724487b07d1b862c583126f84b | |
parent | e5145ffb985ab1fdd72b680806dff4fc00c1877f (diff) |
Revert "Switch from std::sync::mpsc to crossbeam-channel"
@sharkdp [noticed][1] a quite severe performance degredation due to this
change. Switch back to std::sync::mpsc until we can fix the performance
regression.
This reverts commit a4bb734482c7bf3fd4d30081e7d3ce7786a3775e.
[1]: https://github.com/sharkdp/fd/pull/895#issuecomment-1002099369
-rw-r--r-- | Cargo.lock | 11 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/exec/job.rs | 3 | ||||
-rw-r--r-- | src/walk.rs | 10 |
4 files changed, 8 insertions, 17 deletions
@@ -100,16 +100,6 @@ dependencies = [ ] [[package]] -name = "crossbeam-channel" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] name = "crossbeam-utils" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -165,7 +155,6 @@ dependencies = [ "atty", "chrono", "clap", - "crossbeam-channel", "ctrlc", "diff", "dirs-next", @@ -49,7 +49,6 @@ dirs-next = "2.0" normpath = "0.3" chrono = "0.4" once_cell = "1.8.0" -crossbeam-channel = "0.5.1" [dependencies.clap] version = "2.34.0" diff --git a/src/exec/job.rs b/src/exec/job.rs index 0effc44..85b30f1 100644 --- a/src/exec/job.rs +++ b/src/exec/job.rs @@ -1,8 +1,7 @@ use std::path::PathBuf; +use std::sync::mpsc::Receiver; use std::sync::{Arc, Mutex}; -use crossbeam_channel::Receiver; - use crate::error::print_error; use crate::exit_codes::{merge_exitcodes, ExitCode}; use crate::walk::WorkerResult; diff --git a/src/walk.rs b/src/walk.rs index 037baae..0d412ba 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -4,13 +4,13 @@ use std::io; use std::mem; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::{Duration, Instant}; use std::{borrow::Cow, io::Write}; use anyhow::{anyhow, Result}; -use crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender}; use ignore::overrides::OverrideBuilder; use ignore::{self, WalkBuilder}; use once_cell::unsync::OnceCell; @@ -55,7 +55,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> R let first_path_buf = path_iter .next() .expect("Error: Path vector can not be empty"); - let (tx, rx) = unbounded(); + let (tx, rx) = channel(); let mut override_builder = OverrideBuilder::new(first_path_buf.as_path()); @@ -232,7 +232,11 @@ impl<W: Write> ReceiverBuffer<W> { match self.mode { ReceiverMode::Buffering => { // Wait at most until we should switch to streaming - self.rx.recv_deadline(self.deadline) + let now = Instant::now(); + self.deadline + .checked_duration_since(now) + .ok_or(RecvTimeoutError::Timeout) + .and_then(|t| self.rx.recv_timeout(t)) } ReceiverMode::Streaming => { // Wait however long it takes for a result |