Skip to main content

sqlload_python_host/crossing/main/
default_parse_threads.rs

1//! How many threads parse one table's batches by default.
2
3use crate::crossing::constants::MAX_DEFAULT_PARSE_THREADS;
4
5/// One parser per core but one, which the generator's thread keeps, capped at the default.
6pub fn default_parse_threads() -> usize {
7    std::thread::available_parallelism()
8        .map_or(1, |cores| cores.get().saturating_sub(1))
9        .clamp(1, MAX_DEFAULT_PARSE_THREADS)
10}