diff --git a/crates/librqbit/src/storage/middleware/slow.rs b/crates/librqbit/src/storage/middleware/slow.rs index 61726f5..c8d8a9a 100644 --- a/crates/librqbit/src/storage/middleware/slow.rs +++ b/crates/librqbit/src/storage/middleware/slow.rs @@ -31,19 +31,25 @@ impl StorageFactory for SlowStorageFactory { fn init_storage(&self, info: &crate::ManagedTorrentInfo) -> anyhow::Result { Ok(SlowStorage { underlying: self.underlying_factory.init_storage(info)?, - pwrite_all_bufread: Mutex::new( + pwrite_all_bufread: Mutex::new(Box::new( BufReader::new( File::open("/Users/igor/Downloads/rqbit-log-slow-disk.log-pwrite_all").unwrap(), ) - .lines(), - ), - pread_exact_bufread: Mutex::new( + .lines() + .map(|l| l.unwrap().parse().unwrap()) + .collect::>() + .into_iter(), + )), + pread_exact_bufread: Mutex::new(Box::new( BufReader::new( File::open("/Users/igor/Downloads/rqbit-log-slow-disk.log-pread_exact") .unwrap(), ) - .lines(), - ), + .lines() + .map(|l| l.unwrap().parse().unwrap()) + .collect::>() + .into_iter(), + )), }) } @@ -58,13 +64,13 @@ impl StorageFactory for SlowStorageFactory { pub struct SlowStorage { underlying: U, - pwrite_all_bufread: Mutex>>, - pread_exact_bufread: Mutex>>, + pwrite_all_bufread: Mutex + Send + Sync>>, + pread_exact_bufread: Mutex + Send + Sync>>, } -fn sleep_from_reader(r: &Mutex>>) { +fn sleep_from_reader(r: &Mutex + Send + Sync>>) { let mut g = r.lock(); - let micros: u64 = g.next().unwrap().unwrap().parse().unwrap(); + let micros: u64 = g.next().unwrap(); let sl = Duration::from_micros(micros); std::thread::sleep(sl) } diff --git a/crates/rqbit/src/main.rs b/crates/rqbit/src/main.rs index 606db83..5b2422c 100644 --- a/crates/rqbit/src/main.rs +++ b/crates/rqbit/src/main.rs @@ -101,7 +101,7 @@ struct Opts { /// How many blocking tokio threads to spawn to process disk reads/writes. /// Might want to increase if the disk is slow. - #[arg(long = "max-blocking-threads", default_value = "16")] + #[arg(long = "max-blocking-threads", default_value = "8")] max_blocking_threads: u16, /// If set, will write to disk in background and not inline with peer.