Compare commits

..

4 Commits

Author SHA1 Message Date
andy.boot
7bbecd9f87 hack 2022-08-29 11:27:45 +01:00
andy.boot
137bde1099 Fix: Try to stop panics on android.
Catch panics on thread initialization.
2022-08-26 17:12:39 +01:00
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

View File

@@ -11,6 +11,7 @@ mod utils;
use crate::cli::build_cli;
use std::collections::HashSet;
use std::panic;
use std::process;
use sysinfo::{System, SystemExt};
@@ -156,7 +157,10 @@ fn main() {
by_filecount,
ignore_hidden: config.get_ignore_hidden(&options),
};
let _rayon = init_rayon();
let pool = panic::catch_unwind(init_rayon);
if pool.is_err() {
eprintln!("Warning: Could not configure threads {:?}", pool.err());
}
let iso = config.get_iso(&options);
let (top_level_nodes, has_errors) = walk_it(simplified_dirs, walk_data);
@@ -191,17 +195,14 @@ 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;
let s = System::new_all();
let av = s.get_available_memory();
let free = s.get_free_memory();
println!("{}", av);
println!("{}", free);
// Larger stack size to handle cases with lots of nested directories
rayon::ThreadPoolBuilder::new()
.stack_size(usize::pow(1024, 3))
.build_global()
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(())
}
}