mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2231e2d966 |
+13
-14
@@ -11,7 +11,6 @@ mod utils;
|
||||
|
||||
use crate::cli::build_cli;
|
||||
use std::collections::HashSet;
|
||||
use std::panic;
|
||||
use std::process;
|
||||
use sysinfo::{System, SystemExt};
|
||||
|
||||
@@ -157,10 +156,7 @@ fn main() {
|
||||
by_filecount,
|
||||
ignore_hidden: config.get_ignore_hidden(&options),
|
||||
};
|
||||
let pool = panic::catch_unwind(init_rayon);
|
||||
if pool.is_err() {
|
||||
eprintln!("Warning: Could not configure threads {:?}", pool.err());
|
||||
}
|
||||
let _rayon = init_rayon();
|
||||
|
||||
let iso = config.get_iso(&options);
|
||||
let (top_level_nodes, has_errors) = walk_it(simplified_dirs, walk_data);
|
||||
@@ -195,14 +191,17 @@ fn main() {
|
||||
}
|
||||
|
||||
fn init_rayon() -> Result<(), ThreadPoolBuildError> {
|
||||
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()
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user