From 6de18ad557069ac429166252a396c4a5a4e6d366 Mon Sep 17 00:00:00 2001 From: sokorototo Date: Mon, 29 Jul 2024 11:01:47 +0300 Subject: [PATCH] small regression --- Cargo.lock | 21 +++++---------------- vach-cli/Cargo.toml | 5 ++--- vach-cli/src/commands/pack.rs | 3 +-- vach/Cargo.toml | 2 +- vach/src/writer/config.rs | 8 +++----- vach/src/writer/mod.rs | 3 ++- 6 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d01638f5..c3040903 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1093,16 +1093,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "term_size" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "termcolor" version = "1.4.1" @@ -1188,9 +1178,9 @@ dependencies = [ [[package]] name = "vach" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0f7c862de2709c7a39741492c0f2bf9f48518dc7ade68a61f82da1da909221" +checksum = "d6e089a362e16a5ccf60ffa945c8bb29e4f9bea9a2d6b5b6b0463e032c0c9279" dependencies = [ "aes-gcm", "brotli", @@ -1203,7 +1193,7 @@ dependencies = [ [[package]] name = "vach" -version = "0.6.1" +version = "0.6.2" dependencies = [ "aes-gcm", "brotli", @@ -1220,7 +1210,7 @@ name = "vach-benchmarks" version = "0.1.0" dependencies = [ "criterion", - "vach 0.6.1", + "vach 0.6.2", ] [[package]] @@ -1233,8 +1223,7 @@ dependencies = [ "num_cpus", "tabled", "tempfile", - "term_size", - "vach 0.6.0", + "vach 0.6.1", "walkdir", ] diff --git a/vach-cli/Cargo.toml b/vach-cli/Cargo.toml index a2b50ac4..f1b7d9d0 100644 --- a/vach-cli/Cargo.toml +++ b/vach-cli/Cargo.toml @@ -19,12 +19,11 @@ name = "vach" path = "src/main.rs" [dependencies] -vach = { version = "0.6", features = ["all"] } +vach = { version = "0.6.2", features = ["all"] } num_cpus = "1.16.0" clap = "3.1.15" indicatif = "0.17.8" -anyhow = "1.0.81" +anyhow = "1.0.86" tabled = "0.15.0" walkdir = "2.5.0" -term_size = "0.3.2" tempfile = "3.10.1" diff --git a/vach-cli/src/commands/pack.rs b/vach-cli/src/commands/pack.rs index a5ce7d89..3a3acd7a 100644 --- a/vach-cli/src/commands/pack.rs +++ b/vach-cli/src/commands/pack.rs @@ -1,7 +1,6 @@ use std::{ fs::File, io::{self, Read, Write}, - num::NonZeroUsize, }; use std::path::PathBuf; use std::collections::HashSet; @@ -216,7 +215,7 @@ impl CommandTrait for Evaluator { magic, keypair: kp, progress_callback: Some(&callback), - num_threads: `NonZeroUsize::new(num_threads).expect("Jobs can't be zero")`, + num_threads, }; // Construct the builder diff --git a/vach/Cargo.toml b/vach/Cargo.toml index 9529274d..c34f5e07 100644 --- a/vach/Cargo.toml +++ b/vach/Cargo.toml @@ -2,7 +2,7 @@ name = "vach" # NOTE: Make sure spec.txt and vach::VERSION constants are all synced up -version = "0.6.1" +version = "0.6.2" edition = "2021" authors = [ diff --git a/vach/src/writer/config.rs b/vach/src/writer/config.rs index 3fe90e09..e4a893f7 100644 --- a/vach/src/writer/config.rs +++ b/vach/src/writer/config.rs @@ -1,5 +1,3 @@ -use std::{fmt::Debug, num::NonZeroUsize}; - use crate::global::{flags::Flags, reg_entry::RegistryEntry}; #[cfg(feature = "crypto")] @@ -10,7 +8,7 @@ use crate::crypto; pub struct BuilderConfig<'a> { /// Number of threads to spawn during `Builder::dump`, defaults to 4 #[cfg(feature = "multithreaded")] - pub num_threads: NonZeroUsize, + pub num_threads: usize, /// Used to write a unique magic sequence into the write target. pub magic: [u8; crate::MAGIC_LENGTH], /// Flags to be written into the `Header` section of the write target. @@ -36,7 +34,7 @@ pub struct BuilderConfig<'a> { pub progress_callback: Option<&'a dyn Fn(&RegistryEntry)>, } -impl<'a> Debug for BuilderConfig<'a> { +impl<'a> std::fmt::Debug for BuilderConfig<'a> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut f = f.debug_struct("BuilderConfig"); @@ -112,7 +110,7 @@ impl<'a> Default for BuilderConfig<'a> { fn default() -> BuilderConfig<'a> { BuilderConfig { #[cfg(feature = "multithreaded")] - num_threads: NonZeroUsize::new(4).unwrap(), + num_threads: 4, flags: Flags::default(), magic: *crate::DEFAULT_MAGIC, progress_callback: None, diff --git a/vach/src/writer/mod.rs b/vach/src/writer/mod.rs index 15c87930..0152c61e 100644 --- a/vach/src/writer/mod.rs +++ b/vach/src/writer/mod.rs @@ -294,7 +294,8 @@ impl<'a> Builder<'a> { { thread::scope(|s| -> InternalResult<()> { let count = leafs.len(); - let chunk_size = (leafs.len() / config.num_threads).max(leafs.len()); + let chunk_size = leafs.len() / config.num_threads.min(1); + let chunks = leafs.chunks_mut(chunk_size); let encryptor = encryptor.as_ref();