Skip to content

Commit e57361c

Browse files
committed
[lldb/Host] Remove TaskPool and replace its uses with llvm::ThreadPool
Remove LLDB's TaskPool and replace its uses with LLVM's ThreadPool. Differential revision: https://reviews.llvm.org/D78337
1 parent 68a2758 commit e57361c

File tree

7 files changed

+21
-279
lines changed

7 files changed

+21
-279
lines changed

lldb/include/lldb/Host/TaskPool.h

-92
This file was deleted.

lldb/include/lldb/module.modulemap

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ module lldb_Host {
4949
module SocketAddress { header "Host/SocketAddress.h" export * }
5050
module Socket { header "Host/Socket.h" export * }
5151
module StringConvert { textual header "Host/StringConvert.h" export * }
52-
module TaskPool { header "Host/TaskPool.h" export * }
5352
module Terminal { header "Host/Terminal.h" export * }
5453
module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
5554
module Time { header "Host/Time.h" export * }

lldb/source/Host/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ add_host_subdirectory(common
3030
common/SocketAddress.cpp
3131
common/Socket.cpp
3232
common/StringConvert.cpp
33-
common/TaskPool.cpp
3433
common/TCPSocket.cpp
3534
common/Terminal.cpp
3635
common/ThreadLauncher.cpp

lldb/source/Host/common/TaskPool.cpp

-126
This file was deleted.

lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

+21-13
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
1414
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h"
1515
#include "lldb/Core/Module.h"
16-
#include "lldb/Host/TaskPool.h"
1716
#include "lldb/Symbol/ObjectFile.h"
1817
#include "lldb/Utility/Stream.h"
1918
#include "lldb/Utility/Timer.h"
19+
#include "llvm/Support/ThreadPool.h"
2020

2121
using namespace lldb_private;
2222
using namespace lldb;
@@ -71,20 +71,27 @@ void ManualDWARFIndex::Index() {
7171
clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped();
7272
};
7373

74+
// Share one thread pool across operations to avoid the overhead of
75+
// recreating the threads.
76+
llvm::ThreadPool pool;
77+
7478
// Create a task runner that extracts dies for each DWARF unit in a
75-
// separate thread
79+
// separate thread.
7680
// First figure out which units didn't have their DIEs already
7781
// parsed and remember this. If no DIEs were parsed prior to this index
7882
// function call, we are going to want to clear the CU dies after we are
7983
// done indexing to make sure we don't pull in all DWARF dies, but we need
8084
// to wait until all units have been indexed in case a DIE in one
8185
// unit refers to another and the indexes accesses those DIEs.
82-
TaskMapOverInt(0, units_to_index.size(), extract_fn);
86+
for (size_t i = 0; i < units_to_index.size(); ++i)
87+
pool.async(extract_fn, i);
88+
pool.wait();
8389

8490
// Now create a task runner that can index each DWARF unit in a
8591
// separate thread so we can index quickly.
86-
87-
TaskMapOverInt(0, units_to_index.size(), parser_fn);
92+
for (size_t i = 0; i < units_to_index.size(); ++i)
93+
pool.async(parser_fn, i);
94+
pool.wait();
8895

8996
auto finalize_fn = [this, &sets](NameToDIE(IndexSet::*index)) {
9097
NameToDIE &result = m_set.*index;
@@ -93,14 +100,15 @@ void ManualDWARFIndex::Index() {
93100
result.Finalize();
94101
};
95102

96-
TaskPool::RunTasks([&]() { finalize_fn(&IndexSet::function_basenames); },
97-
[&]() { finalize_fn(&IndexSet::function_fullnames); },
98-
[&]() { finalize_fn(&IndexSet::function_methods); },
99-
[&]() { finalize_fn(&IndexSet::function_selectors); },
100-
[&]() { finalize_fn(&IndexSet::objc_class_selectors); },
101-
[&]() { finalize_fn(&IndexSet::globals); },
102-
[&]() { finalize_fn(&IndexSet::types); },
103-
[&]() { finalize_fn(&IndexSet::namespaces); });
103+
pool.async(finalize_fn, &IndexSet::function_basenames);
104+
pool.async(finalize_fn, &IndexSet::function_fullnames);
105+
pool.async(finalize_fn, &IndexSet::function_methods);
106+
pool.async(finalize_fn, &IndexSet::function_selectors);
107+
pool.async(finalize_fn, &IndexSet::objc_class_selectors);
108+
pool.async(finalize_fn, &IndexSet::globals);
109+
pool.async(finalize_fn, &IndexSet::types);
110+
pool.async(finalize_fn, &IndexSet::namespaces);
111+
pool.wait();
104112
}
105113

106114
void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp,

lldb/unittests/Host/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ set (FILES
1111
SocketAddressTest.cpp
1212
SocketTest.cpp
1313
SocketTestUtilities.cpp
14-
TaskPoolTest.cpp
1514
)
1615

1716
if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")

lldb/unittests/Host/TaskPoolTest.cpp

-45
This file was deleted.

0 commit comments

Comments
 (0)