[PATCH] D110018: [lld-macho] Speed up markLive()
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 20 09:41:28 PDT 2021
int3 added a comment.
I'm a bit ambivalent about this change. The typical way that parallel mark-sweep is implemented is via a work-stealing queue. That way we have one lock per thread, instead of all threads contending on one lock. Granted this diff is already an improvement, but perhaps it would be best to implement the optimal solution right off the bat...
================
Comment at: lld/MachO/InputFiles.cpp:278
// Copying requires less memory than constructing a fresh InputSection.
- auto *copy = make<ConcatInputSection>(*isec);
+ auto copy = make<ConcatInputSection>(
+ segname, name, this, data.slice(0, recordSize), align, flags);
----------------
why this change?
================
Comment at: lld/MachO/InputSection.h:120
+ void markLive(uint64_t off) override {
+ const std::lock_guard<std::mutex> l(liveNessMutex);
+ live = true;
----------------
I think this lock isn't necessary... multiple concurrent calls to this method will still end up setting `live` to true
================
Comment at: lld/MachO/InputSection.h:259-260
+ void markLive(uint64_t off) override {
+ const std::lock_guard<std::mutex> l(liveNessMutex);
+ live[off >> power2LiteralSize] = 1;
+ }
----------------
atomics might perform better here, assuming low contention
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110018/new/
https://reviews.llvm.org/D110018
More information about the llvm-commits
mailing list