Compare commits

..

2 Commits

Author SHA1 Message Date
andy.boot
0d0206a5a5 Version: New version 2022-08-25 10:18:18 +01:00
andy.boot
dfce0eec66 Fix: Warn if configuring threads fails
User reported this unwrap could fail, so log an error instead of using a
naked unwrap.
2022-08-25 08:59:15 +01:00
3 changed files with 5 additions and 59 deletions

39
Cargo.lock generated
View File

@@ -68,12 +68,6 @@ dependencies = [
"regex-automata",
]
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
version = "1.0.0"
@@ -124,12 +118,6 @@ dependencies = [
"toml",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "crossbeam-channel"
version = "0.5.6"
@@ -222,7 +210,6 @@ dependencies = [
"regex",
"serde",
"stfu8",
"sysinfo",
"tempfile",
"terminal_size",
"thousands",
@@ -335,15 +322,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "ntapi"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
dependencies = [
"winapi",
]
[[package]]
name = "num_cpus"
version = "1.13.1"
@@ -540,23 +518,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "sysinfo"
version = "0.15.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de94457a09609f33fec5e7fceaf907488967c6c7c75d64da6a7ce6ffdb8b5abd"
dependencies = [
"cc",
"cfg-if",
"core-foundation-sys",
"doc-comment",
"libc",
"ntapi",
"once_cell",
"rayon",
"winapi",
]
[[package]]
name = "tempfile"
version = "3.3.0"

View File

@@ -39,7 +39,6 @@ regex = "1"
config-file = "0.2"
serde = { version = "1.0", features = ["derive"] }
directories = "4"
sysinfo = "0.15"
[target.'cfg(windows)'.dependencies]
winapi-util = "0.1"

View File

@@ -12,7 +12,6 @@ mod utils;
use crate::cli::build_cli;
use std::collections::HashSet;
use std::process;
use sysinfo::{System, SystemExt};
use self::display::draw_it;
use clap::Values;
@@ -20,7 +19,6 @@ use config::get_config;
use dir_walker::{walk_it, WalkData};
use filter::get_biggest;
use filter_type::get_all_file_types;
use rayon::ThreadPoolBuildError;
use regex::Regex;
use std::cmp::max;
use std::path::PathBuf;
@@ -156,7 +154,11 @@ fn main() {
by_filecount,
ignore_hidden: config.get_ignore_hidden(&options),
};
let _rayon = init_rayon();
// Larger stack size to handle cases with lots of nested directories
rayon::ThreadPoolBuilder::new()
.stack_size(usize::pow(1024, 3))
.build_global()
.unwrap_or_else(|e| eprintln!("Warning: Could not configure threads {:?}", e));
let iso = config.get_iso(&options);
let (top_level_nodes, has_errors) = walk_it(simplified_dirs, walk_data);
@@ -189,19 +191,3 @@ fn main() {
)
}
}
fn init_rayon() -> Result<(), ThreadPoolBuildError> {
let large_stack = usize::pow(1024, 3);
// Warning: Creating System is slow, takes ~ 100ms
let s = System::new();
let available = s.get_available_memory() * 1024;
if available > large_stack.try_into().unwrap() {
// Larger stack size to handle cases with lots of nested directories
rayon::ThreadPoolBuilder::new()
.stack_size(large_stack)
.build_global()
} else {
Ok(())
}
}