polars_utils/
ideal_morsel_size.rs

1use std::num::NonZeroUsize;
2use std::sync::OnceLock;
3
4pub fn get_ideal_morsel_size() -> NonZeroUsize {
5    return *IDEAL_MORSEL_SIZE.get_or_init(|| {
6        std::env::var("POLARS_IDEAL_MORSEL_SIZE")
7            .map(|x| {
8                x.parse::<NonZeroUsize>()
9                    .ok()
10                    .unwrap_or_else(|| panic!("invalid value for POLARS_IDEAL_MORSEL_SIZE: {x}"))
11            })
12            .unwrap_or(const { NonZeroUsize::new(100_000).unwrap() })
13    });
14
15    static IDEAL_MORSEL_SIZE: OnceLock<NonZeroUsize> = OnceLock::new();
16}