AdamGS commented on code in PR #21084:
URL: https://github.com/apache/datafusion/pull/21084#discussion_r2969583077


##########
datafusion/common/src/utils/mod.rs:
##########
@@ -923,10 +923,15 @@ pub fn combine_limit(
 ///
 /// This is a wrapper around `std::thread::available_parallelism`, providing a 
default value
 /// of `1` if the system's parallelism cannot be determined.
+///
+/// The result is cached after the first call.
 pub fn get_available_parallelism() -> usize {
-    available_parallelism()
-        .unwrap_or(NonZero::new(1).expect("literal value `1` shouldn't be 
zero"))
-        .get()
+    static PARALLELISM: LazyLock<usize> = LazyLock::new(|| {

Review Comment:
   I think part of it is that `SimplifyContext` doesn't have a builder, we end 
up allocating its internal fields (which includes ConfigOptions, which is what 
ends up calling `get_available_parallelism` like @blaginin pointed out here), 
then immediately overriding the config and schema.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to