diff --git a/clang-tools-extra/clangd/unittests/lit.cfg.py b/clang-tools-extra/clangd/unittests/lit.cfg.py index 48ee5f5d5ab92..33aa9e61f4ce9 100644 --- a/clang-tools-extra/clangd/unittests/lit.cfg.py +++ b/clang-tools-extra/clangd/unittests/lit.cfg.py @@ -1,4 +1,5 @@ import lit.formats +import lit.util config.name = "Clangd Unit Tests" config.test_format = lit.formats.GoogleTest(".", "Tests") @@ -9,6 +10,13 @@ # FIXME: it seems every project has a copy of this logic. Move it somewhere. import platform +# Clangd unittests uses ~4 threads per test. So make sure we don't over commit. +core_count = lit.util.usable_core_count() +# FIXME: Split unittests into groups that use threads, and groups that do not, +# and only limit multi-threaded tests. +lit_config.parallelism_groups["clangd"] = max(1, core_count // 4) +config.parallelism_group = "clangd" + if platform.system() == "Darwin": shlibpath_var = "DYLD_LIBRARY_PATH" elif platform.system() == "Windows":