Skip to content

Commit

Permalink
[clangd][unittests] Limit paralelism for clangd unittests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kadircet committed Sep 6, 2023
1 parent bcdbd0b commit 9a26d2c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clang-tools-extra/clangd/unittests/lit.cfg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import lit.formats
import lit.util

config.name = "Clangd Unit Tests"
config.test_format = lit.formats.GoogleTest(".", "Tests")
Expand All @@ -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":
Expand Down

0 comments on commit 9a26d2c

Please sign in to comment.