Skip to content

Commit

Permalink
optimize thread number
Browse files Browse the repository at this point in the history
  • Loading branch information
YamatoSecurity committed Sep 22, 2023
1 parent ecfcbf8 commit 872c0bd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/detections/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use hashbrown::{HashMap, HashSet};
use itertools::Itertools;
use nested::Nested;
use std::path::{Path, PathBuf};
use std::thread::available_parallelism;

use chrono::{Duration, Local};
use termcolor::{Color, ColorChoice};
Expand Down Expand Up @@ -284,8 +285,8 @@ pub fn get_event_value<'a>(
}

pub fn get_thread_num(thread_number: Option<usize>) -> usize {
let cpu_num = num_cpus::get();
thread_number.unwrap_or(cpu_num)
let cpu_num = available_parallelism().unwrap();
thread_number.unwrap_or(cpu_num.into())
}

pub fn create_tokio_runtime(thread_number: Option<usize>) -> Runtime {
Expand Down

0 comments on commit 872c0bd

Please sign in to comment.