File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
datafusion/common/src/utils Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -945,9 +945,14 @@ pub fn combine_limit(
945945/// This is a wrapper around `std::thread::available_parallelism`, providing a default value
946946/// of `1` if the system's parallelism cannot be determined.
947947pub fn get_available_parallelism ( ) -> usize {
948- available_parallelism ( )
949- . unwrap_or ( NonZero :: new ( 1 ) . expect ( "literal value `1` shouldn't be zero" ) )
950- . get ( )
948+ use std:: sync:: OnceLock ;
949+ static CACHED_PARALLELISM : OnceLock < usize > = OnceLock :: new ( ) ;
950+
951+ * CACHED_PARALLELISM . get_or_init ( || {
952+ available_parallelism ( )
953+ . unwrap_or ( NonZero :: new ( 1 ) . expect ( "literal value `1` shouldn't be zero" ) )
954+ . get ( )
955+ } )
951956}
952957
953958/// Converts a collection of function arguments into an fixed-size array of length N
You can’t perform that action at this time.
0 commit comments