MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_default_worker_count

Function cbm_default_worker_count

src/foundation/system_info.c:318–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316}
317
318int cbm_default_worker_count(bool initial) {
319 /* CBM_WORKERS env override (clamped to [1, CBM_WORKERS_MAX]).
320 * Useful inside containers where sysconf(_SC_NPROCESSORS_ONLN)
321 * reports host CPUs rather than the cgroup's effective CPU quota.
322 * Same precedence shape as other CBM_* env overrides:
323 * explicit override > implicit detection. */
324 char buf[CBM_SZ_32];
325 if (cbm_safe_getenv("CBM_WORKERS", buf, sizeof(buf), NULL) != NULL) {
326 long n = strtol(buf, NULL, CBM_DECIMAL_BASE);
327 if (n >= MIN_WORKERS && n <= CBM_WORKERS_MAX) {
328 return (int)n;
329 }
330 cbm_log_warn("workers.env.invalid", "value", buf, "fallback", "sysconf");
331 }
332
333 cbm_system_info_t info = cbm_system_info();
334 if (initial) {
335 /* Use all cores for initial indexing — user is waiting */
336 return info.total_cores;
337 }
338 /* Incremental: leave headroom for user's apps */
339 int workers = info.perf_cores - SKIP_ONE;
340 return workers > 0 ? workers : MIN_WORKERS;
341}
342
343/* -- Available RAM --------------------------------------------------
344 *

Callers 15

cbm_sem_corpus_finalizeFunction · 0.85
cbm_parallel_forFunction · 0.85
cbm_pipeline_pass_k8sFunction · 0.85
run_extract_resolveFunction · 0.85
closure_probe_surfacesFunction · 0.85
run_closure_deltaFunction · 0.85
effective_worker_countFunction · 0.85
strategy_key_symbolsFunction · 0.85

Calls 2

cbm_safe_getenvFunction · 0.85
cbm_system_infoFunction · 0.85

Tested by 2

pc_env_beginFunction · 0.68
pc_parallel_inputsFunction · 0.68