Skip to content

Commit 21cbd38

Browse files
blagininalamb
andauthored
[branch-53] Planning speed improve (port of #21084) (#21137)
- Port of #21084 to 53 - Related to #21079 Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
1 parent 01df975 commit 21cbd38

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.github/workflows/extended.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ jobs:
173173
ref: ${{ github.event.inputs.pr_head_sha }} # will be empty if triggered by push
174174
submodules: true
175175
fetch-depth: 1
176-
- name: Setup Rust toolchain
177-
uses: ./.github/actions/setup-builder
178-
with:
179-
rust-version: stable
176+
# Don't use setup-builder to avoid configuring RUST_BACKTRACE which is expensive
177+
- name: Install protobuf compiler
178+
run: |
179+
apt-get update && apt-get install -y protobuf-compiler
180180
- name: Run sqllogictest
181181
run: |
182182
cargo test --features backtrace,parquet_encryption --profile release-nonlto --test sqllogictests -- --include-sqlite

datafusion/common/src/utils/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::cmp::{Ordering, min};
3939
use std::collections::HashSet;
4040
use std::num::NonZero;
4141
use std::ops::Range;
42-
use std::sync::Arc;
42+
use std::sync::{Arc, LazyLock};
4343
use std::thread::available_parallelism;
4444

4545
/// Applies an optional projection to a [`SchemaRef`], returning the
@@ -922,10 +922,15 @@ pub fn combine_limit(
922922
///
923923
/// This is a wrapper around `std::thread::available_parallelism`, providing a default value
924924
/// of `1` if the system's parallelism cannot be determined.
925+
///
926+
/// The result is cached after the first call.
925927
pub fn get_available_parallelism() -> usize {
926-
available_parallelism()
927-
.unwrap_or(NonZero::new(1).expect("literal value `1` shouldn't be zero"))
928-
.get()
928+
static PARALLELISM: LazyLock<usize> = LazyLock::new(|| {
929+
available_parallelism()
930+
.unwrap_or(NonZero::new(1).expect("literal value `1` shouldn't be zero"))
931+
.get()
932+
});
933+
*PARALLELISM
929934
}
930935

931936
/// Converts a collection of function arguments into a fixed-size array of length N

0 commit comments

Comments
 (0)