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 @@ -928,9 +928,14 @@ pub fn combine_limit(
928928/// This is a wrapper around `std::thread::available_parallelism`, providing a default value
929929/// of `1` if the system's parallelism cannot be determined.
930930pub fn get_available_parallelism ( ) -> usize {
931- available_parallelism ( )
932- . unwrap_or ( NonZero :: new ( 1 ) . expect ( "literal value `1` shouldn't be zero" ) )
933- . get ( )
931+ use std:: sync:: OnceLock ;
932+ static CACHED_PARALLELISM : OnceLock < usize > = OnceLock :: new ( ) ;
933+
934+ * CACHED_PARALLELISM . get_or_init ( || {
935+ available_parallelism ( )
936+ . unwrap_or ( NonZero :: new ( 1 ) . expect ( "literal value `1` shouldn't be zero" ) )
937+ . get ( )
938+ } )
934939}
935940
936941/// 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