mirror of
https://github.com/bootandy/dust.git
synced 2026-01-30 00:34:24 -08:00
Compare commits
4 Commits
v0.8.3
...
fix_error_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bbecd9f87 | ||
|
|
137bde1099 | ||
|
|
0d0206a5a5 | ||
|
|
dfce0eec66 |
27
src/main.rs
27
src/main.rs
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user