polars_utils/
ideal_morsel_size.rs1use 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 .unwrap_or_else(|_| panic!("invalid value for POLARS_IDEAL_MORSEL_SIZE: {x}"))
10 })
11 .unwrap_or(const { NonZeroUsize::new(100_000).unwrap() })
12 });
13
14 static IDEAL_MORSEL_SIZE: OnceLock<NonZeroUsize> = OnceLock::new();
15}