llunak created this revision.
llunak added reviewers: clayborg, labath.
llunak added a project: LLDB.
Herald added subscribers: JDevlieghere, arphaman.
Herald added a project: All.
llunak requested review of this revision.
Herald added a subscriber: lldb-commits.
As a preparation for parallelizing loading of symbols (D122975
<https://reviews.llvm.org/D122975>), it is necessary to use just one thread
pool to avoid using a thread pool from inside a task of another thread pool.
I don't know if it's acceptable to have a static like this. If it isn't, then I
don't know where to put it (I don't know how to access e.g. Debugger from
ManualDWARFIndex).
The ThreadPool groups change is D123225 <https://reviews.llvm.org/D123225> .
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123226
Files:
lldb/include/lldb/Core/Debugger.h
lldb/source/Core/Debugger.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -13,6 +13,7 @@
#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h"
#include "lldb/Core/DataFileCache.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Progress.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -94,7 +95,8 @@
// Share one thread pool across operations to avoid the overhead of
// recreating the threads.
- llvm::ThreadPool pool(llvm::optimal_concurrency(units_to_index.size()));
+ llvm::ThreadPool &pool = Debugger::GetThreadPool();
+ llvm::ThreadPool::TaskGroup group;
// Create a task runner that extracts dies for each DWARF unit in a
// separate thread.
@@ -105,14 +107,14 @@
// to wait until all units have been indexed in case a DIE in one
// unit refers to another and the indexes accesses those DIEs.
for (size_t i = 0; i < units_to_index.size(); ++i)
- pool.async(extract_fn, i);
- pool.wait();
+ pool.async(group, extract_fn, i);
+ pool.wait(group);
// Now create a task runner that can index each DWARF unit in a
// separate thread so we can index quickly.
for (size_t i = 0; i < units_to_index.size(); ++i)
- pool.async(parser_fn, i);
- pool.wait();
+ pool.async(group, parser_fn, i);
+ pool.wait(group);
auto finalize_fn = [this, &sets, &progress](NameToDIE(IndexSet::*index)) {
NameToDIE &result = m_set.*index;
@@ -122,15 +124,15 @@
progress.Increment();
};
- pool.async(finalize_fn, &IndexSet::function_basenames);
- pool.async(finalize_fn, &IndexSet::function_fullnames);
- pool.async(finalize_fn, &IndexSet::function_methods);
- pool.async(finalize_fn, &IndexSet::function_selectors);
- pool.async(finalize_fn, &IndexSet::objc_class_selectors);
- pool.async(finalize_fn, &IndexSet::globals);
- pool.async(finalize_fn, &IndexSet::types);
- pool.async(finalize_fn, &IndexSet::namespaces);
- pool.wait();
+ pool.async(group, finalize_fn, &IndexSet::function_basenames);
+ pool.async(group, finalize_fn, &IndexSet::function_fullnames);
+ pool.async(group, finalize_fn, &IndexSet::function_methods);
+ pool.async(group, finalize_fn, &IndexSet::function_selectors);
+ pool.async(group, finalize_fn, &IndexSet::objc_class_selectors);
+ pool.async(group, finalize_fn, &IndexSet::globals);
+ pool.async(group, finalize_fn, &IndexSet::types);
+ pool.async(group, finalize_fn, &IndexSet::namespaces);
+ pool.wait(group);
SaveToCache();
}
Index: lldb/source/Core/Debugger.cpp
===================================================================
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -66,6 +66,7 @@
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Process.h"
+#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
@@ -1963,3 +1964,8 @@
return err;
}
+
+llvm::ThreadPool &Debugger::GetThreadPool() {
+ static llvm::ThreadPool threadpool(llvm::optimal_concurrency());
+ return threadpool;
+}
Index: lldb/include/lldb/Core/Debugger.h
===================================================================
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -49,6 +49,7 @@
namespace llvm {
class raw_ostream;
+class ThreadPool;
}
namespace lldb_private {
@@ -377,6 +378,9 @@
return m_broadcaster_manager_sp;
}
+ /// Shared thread poll. Use only with ThreadPool::TaskGroup.
+ static llvm::ThreadPool &GetThreadPool();
+
/// Report warning events.
///
/// Progress events will be delivered to any debuggers that have listeners
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits