[Lldb-commits] [PATCH] D122975: parallelize calling of Module::PreloadSymbols()

Luboš Luňák via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 6 08:34:01 PDT 2022


llunak updated this revision to Diff 420885.
llunak added a comment.

Rebased on ThreadPool groups (D123225 <https://reviews.llvm.org/D123225>) and adding such thread pool to LLDB (D123226 <https://reviews.llvm.org/D123226>).


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,18 @@
 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 = Debugger::GetThreadPool();
+      llvm::ThreadPool::TaskGroup group;
+      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(group, preload_symbols_fn, idx);
+      pool.wait(group);
+    }
     for (size_t idx = 0; idx < num_images; ++idx) {
       ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
       LoadScriptingResourceForModule(module_sp, this);
@@ -2170,11 +2183,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.420885.patch
Type: text/x-patch
Size: 1575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220406/3af37768/attachment.bin>


More information about the lldb-commits mailing list