summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Threading.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-02-19 09:56:28 +0000
committerSam McCall <sam.mccall@gmail.com>2018-02-19 09:56:28 +0000
commitc901c5db7827af0264e281b90efec0bdf7bce61a (patch)
tree14837b86a68b51b1b17046fda350d118f8b42ee3 /clang-tools-extra/clangd/Threading.cpp
parentced2fe68f33d86ffdbd90be321761f7b0dab46c5 (diff)
downloadbcm5719-llvm-c901c5db7827af0264e281b90efec0bdf7bce61a.tar.gz
bcm5719-llvm-c901c5db7827af0264e281b90efec0bdf7bce61a.zip
[clangd] Tracing: name worker threads, and enforce naming scheduled async tasks
Summary: This has a bit of a blast radius, but I think there's enough value in "forcing" us to give names to these async tasks for debugging. Guessing about what multithreaded code is doing is so unfun... The "file" param attached to the tasks may seem to be redundant with the thread names, but note that thread names are truncated to 15 chars on linux! We'll be lucky to get the whole basename... Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43388 llvm-svn: 325480
Diffstat (limited to 'clang-tools-extra/clangd/Threading.cpp')
-rw-r--r--clang-tools-extra/clangd/Threading.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang-tools-extra/clangd/Threading.cpp b/clang-tools-extra/clangd/Threading.cpp
index a238a477198..7d9ad0c6428 100644
--- a/clang-tools-extra/clangd/Threading.cpp
+++ b/clang-tools-extra/clangd/Threading.cpp
@@ -34,7 +34,8 @@ bool AsyncTaskRunner::wait(Deadline D) const {
[&] { return InFlightTasks == 0; });
}
-void AsyncTaskRunner::runAsync(UniqueFunction<void()> Action) {
+void AsyncTaskRunner::runAsync(llvm::Twine Name,
+ UniqueFunction<void()> Action) {
{
std::lock_guard<std::mutex> Lock(Mutex);
++InFlightTasks;
@@ -51,13 +52,14 @@ void AsyncTaskRunner::runAsync(UniqueFunction<void()> Action) {
});
std::thread(
- [](decltype(Action) Action, decltype(CleanupTask)) {
+ [](std::string Name, decltype(Action) Action, decltype(CleanupTask)) {
+ llvm::set_thread_name(Name);
Action();
// Make sure function stored by Action is destroyed before CleanupTask
// is run.
Action = nullptr;
},
- std::move(Action), std::move(CleanupTask))
+ Name.str(), std::move(Action), std::move(CleanupTask))
.detach();
}
OpenPOWER on IntegriCloud