remove all uses of our custom spinlock

This has caused issues and over time we have reduced the use of
spinlocks, it was only used in few places and we still have evidence
that it's causing ANRs.

We use utils::Mutex instead which is a low overhead mutex implementation
on Linux systems.

FIXES=[321101014]
This commit is contained in:
Mathias Agopian
2024-01-19 10:35:49 -08:00
committed by Sungun Park
parent 0736f3c3b3
commit 7b384fb5e8
9 changed files with 11 additions and 131 deletions

View File

@@ -38,7 +38,6 @@ protected:
utils::Arena<utils::ObjectPoolAllocator<Payload>, LockingPolicy::NoLock> mPoolAllocatorNoLock;
utils::Arena<utils::ObjectPoolAllocator<Payload>, std::mutex> mPoolAllocatorStdMutex;
utils::Arena<utils::ObjectPoolAllocator<Payload>, utils::Mutex> mPoolAllocatorUtilsMutex;
utils::Arena<utils::ObjectPoolAllocator<Payload>, LockingPolicy::SpinLock> mPoolAllocatorSpinlock;
utils::Arena<utils::ThreadSafeObjectPoolAllocator<Payload>, LockingPolicy::NoLock> mPoolAllocatorAtomic;
};
@@ -48,7 +47,6 @@ Allocators::Allocators()
: mPoolAllocatorNoLock("nolock", POOL_ITEM_COUNT * sizeof(Payload)),
mPoolAllocatorStdMutex("std::mutex", POOL_ITEM_COUNT * sizeof(Payload)),
mPoolAllocatorUtilsMutex("utils::Mutex", POOL_ITEM_COUNT * sizeof(Payload)),
mPoolAllocatorSpinlock("spinlock", POOL_ITEM_COUNT * sizeof(Payload)),
mPoolAllocatorAtomic("atomic", POOL_ITEM_COUNT * sizeof(Payload)) {
}
@@ -81,15 +79,6 @@ BENCHMARK_DEFINE_F(Allocators, poolAllocator_utils_mutex)(benchmark::State& stat
}
}
BENCHMARK_DEFINE_F(Allocators, poolAllocator_spinlock)(benchmark::State& state) {
auto& pool = mPoolAllocatorSpinlock;
PerformanceCounters pc(state);
for (auto _ : state) {
Payload* p = pool.alloc<Payload>(1);
pool.free(p);
}
}
BENCHMARK_DEFINE_F(Allocators, poolAllocator_atomic)(benchmark::State& state) {
auto& pool = mPoolAllocatorAtomic;
PerformanceCounters pc(state);
@@ -107,10 +96,6 @@ BENCHMARK_REGISTER_F(Allocators, poolAllocator_utils_mutex)
->ThreadRange(1, 4)
->Threads(benchmark::CPUInfo::Get().num_cpus * 2);
BENCHMARK_REGISTER_F(Allocators, poolAllocator_spinlock)
->ThreadRange(1, 4)
->Threads(benchmark::CPUInfo::Get().num_cpus * 2);
BENCHMARK_REGISTER_F(Allocators, poolAllocator_atomic)
->ThreadRange(1, 4)
->Threads(benchmark::CPUInfo::Get().num_cpus * 2);