We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d41540d commit 9638362Copy full SHA for 9638362
quickwit/quickwit-common/src/cpus.rs
@@ -13,6 +13,7 @@
13
// limitations under the License.
14
15
use std::num::NonZero;
16
+use std::sync::OnceLock;
17
18
use tracing::{error, info, warn};
19
@@ -26,6 +27,11 @@ const KUBERNETES_LIMITS_CPU: &str = "KUBERNETES_LIMITS_CPU";
26
27
/// - from the operating system
28
/// - default to 2.
29
pub fn num_cpus() -> usize {
30
+ static NUM_CPUS: OnceLock<usize> = OnceLock::new();
31
+ *NUM_CPUS.get_or_init(num_cpus_aux)
32
+}
33
+
34
+fn num_cpus_aux() -> usize {
35
let num_cpus_from_os_opt = std::thread::available_parallelism()
36
.map(NonZero::get)
37
.inspect_err(|err| {
0 commit comments