[Lldb-commits] [lldb] [lldb] Use os_unfair_lock for the string pool on Darwin (PR #197851)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu May 14 22:25:32 PDT 2026
================
@@ -15,18 +15,71 @@
#include "llvm/Support/Allocator.h"
#include "llvm/Support/DJB.h"
#include "llvm/Support/FormatProviders.h"
-#include "llvm/Support/RWMutex.h"
#include "llvm/Support/Threading.h"
#include <array>
+#include <mutex>
+#include <shared_mutex>
#include <utility>
#include <cinttypes>
#include <cstdint>
#include <cstring>
+#if defined(__APPLE__)
+#include <os/lock.h>
+#endif
+
using namespace lldb_private;
+namespace {
+/// Lock guarding each shard of the ConstString pool. On Apple platforms it
+/// wraps os_unfair_lock, which is significantly faster than pthread_rwlock for
+/// concurrent writes, and roughly on par for concurrent reads. On all other
+/// platforms, it wraps std::shared_mutex, preserving reader/writer concurrency.
+///
+/// The class satisfies both Lockable and SharedLockable so it composes with
+/// std::lock_guard and std::shared_lock.
+class PoolMutex {
----------------
JDevlieghere wrote:
That would simplify things a lot. Done.
https://github.com/llvm/llvm-project/pull/197851
More information about the lldb-commits
mailing list