[Lldb-commits] [PATCH] D32597: Initiate loading of shared libraries in parallel

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 3 12:28:49 PDT 2017

zturner requested changes to this revision.
zturner added inline comments.
This revision now requires changes to proceed.

Comment at: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp:530-560
+  struct loader {
+    DYLDRendezvous::iterator I;
+    ModuleSP m;
+    std::shared_future<void> f;
+  };
+  std::vector<loader> loaders(num_to_load);
+  llvm::ThreadPool load_pool(
I'm still unclear why we're still going down this route of adding a very specialized instance of parallelism to this one place, that is probably going to be less efficient than having a global thread pool (as now you will have to spin up and destroy the entire thread pool every time you go to load shared libraries).

So, rather than keep repeating the same thing over and over, I went and looked into this a little bit.  It turns out LLD has a large library of parallel algorithms in `lld/Include/lld/Parallel.h`.  There is almost nothing specific to LLD in any of these algorithms however, and they should probably be moved to llvm support.  Upon doing so, you will be able to write this code as:

std::vector<ModuleSP> Modules(m_rendevous.size());
llvm::parallel_for_each(make_integer_range(0, m_rendevous.size()), [this, &Modules](int I)
    auto &R = m_rendevous[I];
    Modules[I] = LoadModuleAtAddress(R.file_spec, R.link_addr, R.base_addr, true);
for (const auto &M : Modules)

Please look into making this change.



More information about the lldb-commits mailing list