MCPcopy Create free account
hub / github.com/duckdb/duckdb / GetSystemMaxThreads

Method GetSystemMaxThreads

src/main/config.cpp:583–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581}
582
583idx_t DBConfig::GetSystemMaxThreads(FileSystem &fs) {
584#ifdef DUCKDB_NO_THREADS
585 return 1;
586#else
587 idx_t physical_cores = std::thread::hardware_concurrency();
588#ifdef __linux__
589 if (const char *slurm_cpus = getenv("SLURM_CPUS_ON_NODE")) {
590 idx_t slurm_threads;
591 if (TryCast::Operation<string_t, idx_t>(string_t(slurm_cpus), slurm_threads)) {
592 return MaxValue<idx_t>(slurm_threads, 1);
593 }
594 }
595 return MaxValue<idx_t>(CGroups::GetCPULimit(fs, physical_cores), 1);
596#else
597 return MaxValue<idx_t>(physical_cores, 1);
598#endif
599#endif
600}
601
602idx_t DBConfig::GetSystemAvailableMemory(FileSystem &fs) {
603 // System memory detection

Callers 3

test_threads.cppFile · 0.80
ConfigureMethod · 0.80
ResetGlobalMethod · 0.80

Calls 1

string_tClass · 0.50

Tested by

no test coverage detected