From 1325e98532b716e18e2787b064f09fec528d28d6 Mon Sep 17 00:00:00 2001 From: "moonsik.song" Date: Wed, 25 Nov 2026 17:36:34 +0900 Subject: [PATCH 1/2] fix(asr): CPU thread count in the C ABI; default follows usable CPUs - nemo_speech_asr_backend_config gains `threads` (0 = default), mapped to asr.backend.threads, so an embedding application can size the CPU backend as the CLI and server already can - `threads` follows a `reserved` field: on 64-bit targets the struct had 4 bytes of tail padding, so a field placed there would be covered by the `size` of a caller built against the 0.3.0 header and read its uninitialized padding. With `reserved` the new field starts past the old sizeof and such callers keep the default - The default thread count is min(8, CPUs the process may use) instead of min(8, hardware threads): on Linux it follows the CPU affinity mask (sched_getaffinity) and the cgroup v2 CPU quota as seen at /sys/fs/cgroup/cpu.max, so a container limited to 4 CPUs on a 48-thread host takes 4 threads, not 8. cgroup v1 and a cgroup seen from the host namespace are not read. Other platforms keep the hardware thread count - One helper, common/cpu_threads.h, replaces the three copies of the default (ASR backend, MagpieTTS, SALM decoder) - tests: cpu_threads checks the cpu.max parsing on every platform, the range of the default, and that a single-CPU affinity mask gives one thread Fixes #108 Signed-off-by: moonsik.song --- docs/sdk.md | 1 + include/nemo_speech/asr.h | 4 ++ include/nemo_speech/tts.h | 2 +- src/asr/CMakeLists.txt | 3 +- src/asr/c_api.cpp | 2 + src/asr/recognizer.cpp | 9 +--- src/asr/recognizer.h | 4 +- src/common/cpu_threads.h | 52 +++++++++++++++++++ src/speechlm/salm_recognizer.cpp | 10 ++-- src/tts/magpietts/config.cpp | 2 +- src/tts/magpietts/runtime.cpp | 10 +--- src/tts/magpietts/runtime.h | 2 +- tests/cpp/CMakeLists.txt | 5 ++ tests/cpp/common/test_cpu_threads.cpp | 73 +++++++++++++++++++++++++++ 14 files changed, 152 insertions(+), 27 deletions(-) create mode 100644 src/common/cpu_threads.h create mode 100644 tests/cpp/common/test_cpu_threads.cpp diff --git a/docs/sdk.md b/docs/sdk.md index 2dbae8a2..0fbd37f5 100644 --- a/docs/sdk.md +++ b/docs/sdk.md @@ -88,6 +88,7 @@ int transcribe(const float* samples, size_t count, int sample_rate) { nemo_speech_asr_backend_config backend{}; backend.size = sizeof(backend); backend.gpu = 0; // -1 for CPU + // backend.threads = 4; // CPU backend threads; 0 = min(8, CPUs the process may use) nemo_speech_asr_model_config model{}; model.size = sizeof(model); diff --git a/include/nemo_speech/asr.h b/include/nemo_speech/asr.h index 8658345a..cbd3557e 100644 --- a/include/nemo_speech/asr.h +++ b/include/nemo_speech/asr.h @@ -63,6 +63,10 @@ typedef enum nemo_speech_asr_decoder_kind { typedef struct nemo_speech_asr_backend_config { size_t size; int32_t gpu; // -1 = CPU + // Unused. Fills what was tail padding on 64-bit targets, so `size` from a caller built + // before `threads` existed never covers it. + int32_t reserved; + int32_t threads; // CPU backend threads; 0 = min(8, usable CPUs) } nemo_speech_asr_backend_config; typedef struct nemo_speech_asr_model_config { diff --git a/include/nemo_speech/tts.h b/include/nemo_speech/tts.h index 9cb2547f..d07048ec 100644 --- a/include/nemo_speech/tts.h +++ b/include/nemo_speech/tts.h @@ -76,7 +76,7 @@ typedef struct nemo_speech_tts_model_config { typedef struct nemo_speech_tts_runtime_config { size_t size; int32_t speaker; - int32_t threads; // CPU threads; 0 = min(8, hardware threads) + int32_t threads; // CPU threads; 0 = min(8, usable CPUs) int32_t codec_threads; // 0 = threads int32_t seed; int32_t steps; diff --git a/src/asr/CMakeLists.txt b/src/asr/CMakeLists.txt index 32a9ee36..af3c1f55 100644 --- a/src/asr/CMakeLists.txt +++ b/src/asr/CMakeLists.txt @@ -91,7 +91,8 @@ target_include_directories(nemo_speech_asr_c PUBLIC $ $) target_compile_definitions(nemo_speech_asr_c PRIVATE NEMO_SPEECH_ASR_BUILD) -# SOVERSION 2: nemo_speech_asr_salm_config grew (n_cpu_moe, batched) +# SOVERSION 2: nemo_speech_asr_salm_config grew (n_cpu_moe, batched); since then +# nemo_speech_asr_backend_config grew too (reserved, threads), append-only, same SOVERSION set_target_properties(nemo_speech_asr_c PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON diff --git a/src/asr/c_api.cpp b/src/asr/c_api.cpp index 184d0cc1..3ed2fa94 100644 --- a/src/asr/c_api.cpp +++ b/src/asr/c_api.cpp @@ -72,6 +72,8 @@ to_config(const nemo_speech_asr_recognizer_config* c) { const auto* b = c->backend; if (HAS_FIELD(b, nemo_speech_asr_backend_config, gpu)) cfg.backend.gpu = b->gpu; + if (HAS_FIELD(b, nemo_speech_asr_backend_config, threads) && b->threads > 0) + cfg.backend.threads = b->threads; } if (HAS_FIELD(c, nemo_speech_asr_recognizer_config, model) && c->model) { const auto* m = c->model; diff --git a/src/asr/recognizer.cpp b/src/asr/recognizer.cpp index e5f7e431..eb4ebe6f 100644 --- a/src/asr/recognizer.cpp +++ b/src/asr/recognizer.cpp @@ -15,6 +15,7 @@ #include #include +#include "cpu_threads.h" #include "gguf.h" #include "model.h" #include "silero_vad.h" @@ -45,13 +46,7 @@ make_backend(const BackendConfig& backend) { p.use_gpu = (backend.gpu >= 0); p.gpu_device_idx = std::max(backend.gpu, 0); p.pe_bin_path = const_cast(""); - if (backend.threads > 0) { - p.n_threads = backend.threads; - } else { - // More busy-waiting CPU workers than hardware threads slows the graph down. - const unsigned hw = std::thread::hardware_concurrency(); - p.n_threads = hw > 0 ? std::min(8, static_cast(hw)) : 8; - } + p.n_threads = backend.threads > 0 ? backend.threads : common::default_cpu_threads(); return std::make_unique(p); } diff --git a/src/asr/recognizer.h b/src/asr/recognizer.h index 0b0f804e..393608e4 100644 --- a/src/asr/recognizer.h +++ b/src/asr/recognizer.h @@ -31,10 +31,10 @@ class Recognizer; struct BackendConfig { int gpu = 0; // -1 = CPU - int threads = 0; // CPU backend threads; 0 = min(8, hardware threads) + int threads = 0; // CPU backend threads; 0 = min(8, usable CPUs) void Register(common::ParameterParser& p) { p.Register("gpu", &gpu, "GPU device index (-1 = CPU)", {"--gpu", "-g"}); - p.Register("threads", &threads, "CPU backend threads (0 = min(8, hardware threads))"); + p.Register("threads", &threads, "CPU backend threads (0 = min(8, usable CPUs))"); } }; diff --git a/src/common/cpu_threads.h b/src/common/cpu_threads.h new file mode 100644 index 00000000..fcf20ecb --- /dev/null +++ b/src/common/cpu_threads.h @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +// Default CPU thread count of the compute backends. +#pragma once + +#include +#include +#include +#include + +#if defined(__linux__) +#include +#endif + +namespace nemo_speech::common { + +// CPU limit in a cgroup v2 cpu.max file (" " in microseconds, or "max "), +// rounded up to whole CPUs. 0 = no limit, also when the file is missing or unreadable. +inline int +cgroup_cpu_limit(const char* cpu_max_path) { + long long quota = 0; + long long period = 0; + std::FILE* f = std::fopen(cpu_max_path, "r"); + if (!f) + return 0; + const bool parsed = std::fscanf(f, "%lld %lld", "a, &period) == 2; + std::fclose(f); + if (!parsed || quota <= 0 || period <= 0) + return 0; + const long long cpus = quota / period + (quota % period != 0 ? 1 : 0); + return static_cast(std::min(cpus, INT_MAX)); +} + +// min(8, CPUs this process may use). More busy-waiting CPU workers than usable CPUs slows +// the graphs down, so on Linux the count follows the CPU affinity mask and the cgroup v2 CPU +// quota as seen at /sys/fs/cgroup/cpu.max (a container limited to 4 CPUs gets 4 threads, +// whatever the host has). +inline int +default_cpu_threads() { + int cpus = static_cast(std::thread::hardware_concurrency()); +#if defined(__linux__) + // The calling thread's mask, which the backend's workers inherit. + cpu_set_t set; + if (sched_getaffinity(0, sizeof(set), &set) == 0) + cpus = CPU_COUNT(&set); + if (const int limit = cgroup_cpu_limit("/sys/fs/cgroup/cpu.max"); limit > 0) + cpus = std::min(cpus, limit); +#endif + return cpus > 0 ? std::min(8, cpus) : 8; +} + +} // namespace nemo_speech::common diff --git a/src/speechlm/salm_recognizer.cpp b/src/speechlm/salm_recognizer.cpp index 5759484d..cb0e5d69 100644 --- a/src/speechlm/salm_recognizer.cpp +++ b/src/speechlm/salm_recognizer.cpp @@ -22,6 +22,7 @@ #include #include "audio_resampler.h" +#include "cpu_threads.h" #include "errors.h" #include "salm_engine.h" #include "salm_guards.h" @@ -60,12 +61,9 @@ engine_config(const asr::RecognizerConfig& c) { out.ctc_path = s.ctc_path; out.llm_path = c.model.path; out.gpu = c.backend.gpu; - // host-side decoder work: asr.backend.threads, as for the other models (0 = min(8, hardware - // threads)) - const unsigned hw = std::thread::hardware_concurrency(); - out.threads = c.backend.threads > 0 ? c.backend.threads - : hw > 0 ? std::min(8, static_cast(hw)) - : 8; + // host-side decoder work: asr.backend.threads, as for the other models (0 = min(8, usable + // CPUs)) + out.threads = c.backend.threads > 0 ? c.backend.threads : common::default_cpu_threads(); out.max_sequences = s.max_sequences; out.n_ctx_per_sequence = s.n_ctx_per_sequence; out.max_context = s.max_context; diff --git a/src/tts/magpietts/config.cpp b/src/tts/magpietts/config.cpp index ed22b6d3..e1c09ab5 100644 --- a/src/tts/magpietts/config.cpp +++ b/src/tts/magpietts/config.cpp @@ -136,7 +136,7 @@ register_runtime_config(common::ParameterParser& p, MagpieRuntimeConfig& c) { p.Register("codec-model", &c.codec_model, "NanoCodec decoder GGUF path"); p.Register("speaker", &c.speaker, "Default baked speaker index"); p.Register( - "threads", &c.threads, "CPU threads for Magpie and codec (0 = min(8, hardware threads))", + "threads", &c.threads, "CPU threads for Magpie and codec (0 = min(8, usable CPUs))", {"--threads"}); p.Register("codec-threads", &c.codec_threads, "Codec CPU threads; 0 uses threads"); p.Register("seed", &c.seed, "Default RNG seed; -1 uses current time"); diff --git a/src/tts/magpietts/runtime.cpp b/src/tts/magpietts/runtime.cpp index edff0961..78ff51ac 100644 --- a/src/tts/magpietts/runtime.cpp +++ b/src/tts/magpietts/runtime.cpp @@ -7,9 +7,9 @@ #include #include #include -#include #include +#include "cpu_threads.h" #include "magpietts.h" #include "model_logging.h" #include "token_utils.h" @@ -170,13 +170,7 @@ class MagpieTtsRuntime::Impl { params.warmup_tokens = tokens; params.warmup_token_chunks = token_chunks; params.speaker = options.speaker >= 0 ? options.speaker : config_.speaker; - if (config_.threads > 0) { - params.threads = config_.threads; - } else { - // More busy-waiting CPU workers than hardware threads slows the graphs down. - const unsigned hw = std::thread::hardware_concurrency(); - params.threads = hw > 0 ? std::min(8, static_cast(hw)) : 8; - } + params.threads = config_.threads > 0 ? config_.threads : common::default_cpu_threads(); params.codec_threads = config_.codec_threads > 0 ? config_.codec_threads : params.threads; params.seed = options.seed >= 0 ? options.seed : config_.seed; params.steps = options.steps > 0 ? options.steps : config_.steps; diff --git a/src/tts/magpietts/runtime.h b/src/tts/magpietts/runtime.h index 684dfcfd..b7703c4d 100644 --- a/src/tts/magpietts/runtime.h +++ b/src/tts/magpietts/runtime.h @@ -32,7 +32,7 @@ struct MagpieRuntimeConfig { std::string magpie_model; std::string codec_model; int speaker = 0; - int threads = 0; // 0 = min(8, hardware threads) + int threads = 0; // 0 = min(8, usable CPUs) int codec_threads = 0; // 0 = threads int seed = -1; int steps = -1; diff --git a/tests/cpp/CMakeLists.txt b/tests/cpp/CMakeLists.txt index 189d4911..680fb305 100644 --- a/tests/cpp/CMakeLists.txt +++ b/tests/cpp/CMakeLists.txt @@ -20,6 +20,11 @@ add_executable(test_subtitles target_link_libraries(test_subtitles PRIVATE nemo_speech_common) add_test(NAME subtitles COMMAND test_subtitles) +add_executable(test_cpu_threads + ${CMAKE_SOURCE_DIR}/tests/cpp/common/test_cpu_threads.cpp) +target_link_libraries(test_cpu_threads PRIVATE nemo_speech_common) +add_test(NAME cpu_threads COMMAND test_cpu_threads) + add_executable(test_audio_ingest ${CMAKE_SOURCE_DIR}/tests/cpp/common/test_audio_ingest.cpp) target_link_libraries(test_audio_ingest PRIVATE nemo_speech_common) diff --git a/tests/cpp/common/test_cpu_threads.cpp b/tests/cpp/common/test_cpu_threads.cpp new file mode 100644 index 00000000..2cd40406 --- /dev/null +++ b/tests/cpp/common/test_cpu_threads.cpp @@ -0,0 +1,73 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include +#include +#include +#include + +#if defined(__linux__) +#include +#endif + +#include "cpu_threads.h" + +namespace { + +void +require(bool condition, const char* message) { + if (!condition) { + std::cerr << "FAIL: " << message << '\n'; + std::exit(1); + } +} + +int +limit_of(const std::string& path, const char* cpu_max) { + std::ofstream(path) << cpu_max; + return nemo_speech::common::cgroup_cpu_limit(path.c_str()); +} + +} // namespace + +int +main() { + using nemo_speech::common::cgroup_cpu_limit; + using nemo_speech::common::default_cpu_threads; + + const std::string path = + (std::filesystem::temp_directory_path() / "nemo_speech_test_cpu_max").string(); + require(limit_of(path, "max 100000\n") == 0, "max is no limit"); + require(limit_of(path, "200000 100000\n") == 2, "two CPUs"); + require(limit_of(path, "250000 100000\n") == 3, "a fractional quota rounds up"); + require(limit_of(path, "0 100000\n") == 0, "a zero quota is no limit"); + require(limit_of(path, "9223372036854775807 1\n") == INT_MAX, "a huge quota does not wrap"); + require(limit_of(path, "") == 0, "an empty file is no limit"); + std::remove(path.c_str()); + require(cgroup_cpu_limit(path.c_str()) == 0, "a missing file is no limit"); + + const int threads = default_cpu_threads(); + std::cout << "default_cpu_threads: " << threads << '\n'; + require(threads >= 1 && threads <= 8, "default is within [1, 8]"); +#if defined(__linux__) + // The mask does not fit a cpu_set_t on hosts with more than 1024 CPUs; the library falls + // back to the hardware thread count there. + cpu_set_t allowed; + if (sched_getaffinity(0, sizeof(allowed), &allowed) == 0) { + require(threads <= CPU_COUNT(&allowed), "default does not exceed the affinity mask"); + // Pin the process to one of its CPUs: the default follows the mask, not the host. + int cpu = 0; + while (!CPU_ISSET(cpu, &allowed)) ++cpu; + cpu_set_t one; + CPU_ZERO(&one); + CPU_SET(cpu, &one); + require(sched_setaffinity(0, sizeof(one), &one) == 0, "sched_setaffinity"); + require(default_cpu_threads() == 1, "one usable CPU gives one thread"); + } +#endif + std::cout << "PASS\n"; + return 0; +} From 5081b713ac2ce4fc29403048c2564b991aa0952a Mon Sep 17 00:00:00 2001 From: "moonsik.song" Date: Thu, 26 Nov 2026 14:16:21 +0900 Subject: [PATCH 2/2] fix(asr): private fixture directory in cpu_threads test; say which CPU limits are read - tests: cpu_threads writes its cpu.max fixture into a directory created for the run (exclusive create under the temporary directory, random name) and removes only that directory, so concurrent runs do not share the file and a path placed there beforehand is not followed - docs/sdk.md, asr.h, tts.h: the `threads` default names what is checked: on Linux the CPU affinity mask and the cgroup v2 quota, a cgroup v1 quota is not read, other platforms use the hardware thread count - CLI help for asr.backend.threads and the MagpieTTS threads option, and the MagpieRuntimeConfig comment, carry the short form of the same qualifier Signed-off-by: moonsik.song --- docs/sdk.md | 4 +++- include/nemo_speech/asr.h | 4 +++- include/nemo_speech/tts.h | 4 +++- src/asr/recognizer.h | 4 +++- src/tts/magpietts/config.cpp | 4 +++- src/tts/magpietts/runtime.h | 2 +- tests/cpp/common/test_cpu_threads.cpp | 15 +++++++++++---- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/docs/sdk.md b/docs/sdk.md index 0fbd37f5..0d9d7cca 100644 --- a/docs/sdk.md +++ b/docs/sdk.md @@ -88,7 +88,9 @@ int transcribe(const float* samples, size_t count, int sample_rate) { nemo_speech_asr_backend_config backend{}; backend.size = sizeof(backend); backend.gpu = 0; // -1 for CPU - // backend.threads = 4; // CPU backend threads; 0 = min(8, CPUs the process may use) + // backend.threads = 4; // CPU backend threads; 0 = min(8, usable CPUs). On Linux that + // follows the CPU affinity mask and the cgroup v2 quota (a cgroup v1 quota is not read); + // other platforms use the hardware thread count. nemo_speech_asr_model_config model{}; model.size = sizeof(model); diff --git a/include/nemo_speech/asr.h b/include/nemo_speech/asr.h index cbd3557e..8573f4cb 100644 --- a/include/nemo_speech/asr.h +++ b/include/nemo_speech/asr.h @@ -66,7 +66,9 @@ typedef struct nemo_speech_asr_backend_config { // Unused. Fills what was tail padding on 64-bit targets, so `size` from a caller built // before `threads` existed never covers it. int32_t reserved; - int32_t threads; // CPU backend threads; 0 = min(8, usable CPUs) + // CPU backend threads; 0 = min(8, usable CPUs): on Linux the CPU affinity mask and the + // cgroup v2 quota (a cgroup v1 quota is not read), elsewhere the hardware thread count. + int32_t threads; } nemo_speech_asr_backend_config; typedef struct nemo_speech_asr_model_config { diff --git a/include/nemo_speech/tts.h b/include/nemo_speech/tts.h index d07048ec..925e6a93 100644 --- a/include/nemo_speech/tts.h +++ b/include/nemo_speech/tts.h @@ -76,7 +76,9 @@ typedef struct nemo_speech_tts_model_config { typedef struct nemo_speech_tts_runtime_config { size_t size; int32_t speaker; - int32_t threads; // CPU threads; 0 = min(8, usable CPUs) + // CPU threads; 0 = min(8, usable CPUs): on Linux the CPU affinity mask and the cgroup v2 + // quota (a cgroup v1 quota is not read), elsewhere the hardware thread count. + int32_t threads; int32_t codec_threads; // 0 = threads int32_t seed; int32_t steps; diff --git a/src/asr/recognizer.h b/src/asr/recognizer.h index 393608e4..36d035d1 100644 --- a/src/asr/recognizer.h +++ b/src/asr/recognizer.h @@ -34,7 +34,9 @@ struct BackendConfig { int threads = 0; // CPU backend threads; 0 = min(8, usable CPUs) void Register(common::ParameterParser& p) { p.Register("gpu", &gpu, "GPU device index (-1 = CPU)", {"--gpu", "-g"}); - p.Register("threads", &threads, "CPU backend threads (0 = min(8, usable CPUs))"); + p.Register( + "threads", &threads, + "CPU backend threads (0 = min(8, usable CPUs: Linux affinity and cgroup v2 quota))"); } }; diff --git a/src/tts/magpietts/config.cpp b/src/tts/magpietts/config.cpp index e1c09ab5..c2276ead 100644 --- a/src/tts/magpietts/config.cpp +++ b/src/tts/magpietts/config.cpp @@ -136,7 +136,9 @@ register_runtime_config(common::ParameterParser& p, MagpieRuntimeConfig& c) { p.Register("codec-model", &c.codec_model, "NanoCodec decoder GGUF path"); p.Register("speaker", &c.speaker, "Default baked speaker index"); p.Register( - "threads", &c.threads, "CPU threads for Magpie and codec (0 = min(8, usable CPUs))", + "threads", &c.threads, + "CPU threads for Magpie and codec (0 = min(8, usable CPUs: Linux affinity and cgroup v2 " + "quota))", {"--threads"}); p.Register("codec-threads", &c.codec_threads, "Codec CPU threads; 0 uses threads"); p.Register("seed", &c.seed, "Default RNG seed; -1 uses current time"); diff --git a/src/tts/magpietts/runtime.h b/src/tts/magpietts/runtime.h index b7703c4d..75badfc7 100644 --- a/src/tts/magpietts/runtime.h +++ b/src/tts/magpietts/runtime.h @@ -32,7 +32,7 @@ struct MagpieRuntimeConfig { std::string magpie_model; std::string codec_model; int speaker = 0; - int threads = 0; // 0 = min(8, usable CPUs) + int threads = 0; // 0 = min(8, usable CPUs: Linux affinity and cgroup v2 quota) int codec_threads = 0; // 0 = threads int seed = -1; int steps = -1; diff --git a/tests/cpp/common/test_cpu_threads.cpp b/tests/cpp/common/test_cpu_threads.cpp index 2cd40406..9be9c4ce 100644 --- a/tests/cpp/common/test_cpu_threads.cpp +++ b/tests/cpp/common/test_cpu_threads.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include #include #include #include +#include #include #if defined(__linux__) @@ -38,15 +38,22 @@ main() { using nemo_speech::common::cgroup_cpu_limit; using nemo_speech::common::default_cpu_threads; - const std::string path = - (std::filesystem::temp_directory_path() / "nemo_speech_test_cpu_max").string(); + // A directory of this run only: create_directory fails on a name that exists, so runs do not + // share the fixture and nothing placed in the temporary directory beforehand is followed. + std::filesystem::path dir; + std::random_device random; + do { + dir = std::filesystem::temp_directory_path() / + ("nemo_speech_test_cpu_threads_" + std::to_string(random())); + } while (!std::filesystem::create_directory(dir)); + const std::string path = (dir / "cpu.max").string(); require(limit_of(path, "max 100000\n") == 0, "max is no limit"); require(limit_of(path, "200000 100000\n") == 2, "two CPUs"); require(limit_of(path, "250000 100000\n") == 3, "a fractional quota rounds up"); require(limit_of(path, "0 100000\n") == 0, "a zero quota is no limit"); require(limit_of(path, "9223372036854775807 1\n") == INT_MAX, "a huge quota does not wrap"); require(limit_of(path, "") == 0, "an empty file is no limit"); - std::remove(path.c_str()); + std::filesystem::remove_all(dir); require(cgroup_cpu_limit(path.c_str()) == 0, "a missing file is no limit"); const int threads = default_cpu_threads();