Skip to content

Commit 9a26d2c

Browse files
committed
[clangd][unittests] Limit paralelism for clangd unittests
We started seeing a lot of timeouts that align with the change in lit to execute gtests in shards. The logic there assumes tests are single-threaded, which is the case for most of the LLVM, hence they pick #shards ~ #cores (by slightly overshooting). There are enough unittests in clangd that rely on multi-threading, they can create arbitrarily many threads but we limit amount of meaningful work to ~4 thread per process. This change ensures that we're accounting for that paralelism when executing clangd tests and not overloading test executors. In theory the change overestimates the requirements, not all tests are multi-threaded, but it doesn't seem to be resulting in any regressions on my local runs. Fixes #64964. Fixes clangd/clangd#1712.
1 parent bcdbd0b commit 9a26d2c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clang-tools-extra/clangd/unittests/lit.cfg.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import lit.formats
2+
import lit.util
23

34
config.name = "Clangd Unit Tests"
45
config.test_format = lit.formats.GoogleTest(".", "Tests")
@@ -9,6 +10,13 @@
910
# FIXME: it seems every project has a copy of this logic. Move it somewhere.
1011
import platform
1112

13+
# Clangd unittests uses ~4 threads per test. So make sure we don't over commit.
14+
core_count = lit.util.usable_core_count()
15+
# FIXME: Split unittests into groups that use threads, and groups that do not,
16+
# and only limit multi-threaded tests.
17+
lit_config.parallelism_groups["clangd"] = max(1, core_count // 4)
18+
config.parallelism_group = "clangd"
19+
1220
if platform.system() == "Darwin":
1321
shlibpath_var = "DYLD_LIBRARY_PATH"
1422
elif platform.system() == "Windows":

0 commit comments

Comments
 (0)