use std::thread;
pub(crate) const DEFAULT_MIN_BUFFER_SIZE: usize = 4 * 1024;
pub(crate) const fn default_tls_cache_size(num_cpus: usize) -> usize {
match num_cpus {
0..=2 => 2,
3..=4 => 4,
5..=8 => 6,
_ => 8,
}
}
pub(crate) const fn default_max_buffers_per_class(num_cpus: usize) -> usize {
const BASE: usize = 32;
let scaling = match num_cpus {
0..16 => 1,
16..32 => 2,
32..64 => 3,
_ => 4,
};
BASE * scaling
}
pub(crate) const fn default_batch_size(tls_cache_size: usize) -> usize {
let half = tls_cache_size / 2;
if half < 2 { 2 } else { half }
}
pub(crate) fn cpu_count() -> usize {
thread::available_parallelism().map_or(4, std::num::NonZero::get)
}