[Lldb-commits] [PATCH] D122975: parallelize calling of Module::PreloadSymbols()
Luboš Luňák via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 5 07:00:18 PDT 2022
llunak updated this revision to Diff 420492.
llunak retitled this revision from "parallelize module loading in DynamicLoaderPOSIXDYLD()" to "parallelize calling of Module::PreloadSymbols()".
llunak edited the summary of this revision.
llunak added a reviewer: jingham.
llunak added a comment.
Ok, parallelizing of only Module::PreloadSymbols() was simpler than I expected and it also works, so I've reworked the patch to do that.
This change now requires D123128 <https://reviews.llvm.org/D123128> and also adding the grouping ability to ThreadPool, which I haven't done yet.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122975/new/
https://reviews.llvm.org/D122975
Files:
lldb/source/Target/Target.cpp
Index: lldb/source/Target/Target.cpp
===================================================================
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -62,6 +62,7 @@
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SetVector.h"
+#include "llvm/Support/ThreadPool.h"
#include <memory>
#include <mutex>
@@ -1623,6 +1624,17 @@
void Target::ModulesDidLoad(ModuleList &module_list) {
const size_t num_images = module_list.GetSize();
if (m_valid && num_images) {
+ if (GetPreloadSymbols()) {
+ // Try to preload symbols in parallel.
+ llvm::ThreadPool pool(llvm::optimal_concurrency(num_images));
+ auto preload_symbols_fn = [&](size_t idx) {
+ ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
+ module_sp->PreloadSymbols();
+ };
+ for (size_t idx = 0; idx < num_images; ++idx)
+ pool.async(preload_symbols_fn, idx);
+ pool.wait();
+ }
for (size_t idx = 0; idx < num_images; ++idx) {
ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
LoadScriptingResourceForModule(module_sp, this);
@@ -2170,11 +2182,6 @@
});
}
- // Preload symbols outside of any lock, so hopefully we can do this for
- // each library in parallel.
- if (GetPreloadSymbols())
- module_sp->PreloadSymbols();
-
llvm::SmallVector<ModuleSP, 1> replaced_modules;
for (ModuleSP &old_module_sp : old_modules) {
if (m_images.GetIndexForModule(old_module_sp.get()) !=
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122975.420492.patch
Type: text/x-patch
Size: 1531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220405/b669fbfd/attachment.bin>
More information about the lldb-commits
mailing list