[Lldb-commits] [lldb] DynamicLoaderDarwin load images in parallel with preload (PR #110646)
Dmitrii Galimzianov via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 15 10:57:08 PDT 2024
================
@@ -642,26 +652,86 @@ ModuleSP DynamicLoaderDarwin::GetDYLDModule() {
void DynamicLoaderDarwin::ClearDYLDModule() { m_dyld_module_wp.reset(); }
+template <typename InputIterator, typename ResultType>
+static std::vector<ResultType> parallel_map(
+ llvm::ThreadPoolInterface &threadPool, InputIterator first,
+ InputIterator last,
+ llvm::function_ref<ResultType(
+ const typename std::iterator_traits<InputIterator>::value_type &)>
+ transform) {
+ const auto size = std::distance(first, last);
+ std::vector<ResultType> results(size);
+ if (size > 0) {
+ llvm::ThreadPoolTaskGroup taskGroup(threadPool);
+ auto it = first;
+ for (ssize_t i = 0; i < size; ++i, ++it) {
+ taskGroup.async([&, i, it]() { results[i] = transform(*it); });
+ }
+ taskGroup.wait();
+ }
+ return results;
+}
----------------
DmT021 wrote:
@jasonmolenda @JDevlieghere I decided to inline the helpers. I still think we are mixing important and utilitary code here and it's less than ideal. But at the same time, I fully understand the readability issue. What's also important here the signatures of the map functions aren't ideal to be considered "general purpose helpers". Namely, they expect `std::distance` to be O(1) which isn't always the case with the current template constraints. So I think if we are going to use the same technique in other places (e.g. `Target::SetExecutableModule` and other dynamic loader plugins) - we may want to write better (more general) implementations for these helpers in some common place.
PS Sorry for the long answer, it took me a while to come up with the decision here.
https://github.com/llvm/llvm-project/pull/110646
More information about the lldb-commits
mailing list