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


##########
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:
   Hmm great find!
   
   Perhaps there also seems to go something wrong with 
`rewrite_with_subqueries` + SimplifyExpressions that make it call so often / 
create it so often.



-- 
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