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()) !=


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()) !=
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to