proxygen
|
#include <algorithm>
#include <cmath>
#include <condition_variable>
#include <numeric>
#include <thread>
#include <vector>
#include <google/base/spinlock.h>
#include <folly/Benchmark.h>
#include <folly/SharedMutex.h>
#include <folly/synchronization/DistributedMutex.h>
#include <folly/synchronization/SmallLocks.h>
Go to the source code of this file.
Classes | |
class | InitLock< Lock > |
class | GoogleSpinLockAdapter |
struct | VirtualBase |
struct | VirtualImpl |
Macros | |
#define | BENCH_BASE(...) FB_VA_GLUE(BENCHMARK_NAMED_PARAM, (__VA_ARGS__)) |
#define | BENCH_REL(...) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM, (__VA_ARGS__)) |
#define | FairnessTest(type) |
Functions | |
DEFINE_int32 (work, 100,"Number of work cycles") | |
DEFINE_int32 (unlocked_work, 1000,"Number of unlocked work cycles") | |
DEFINE_int32 (threads, std::thread::hardware_concurrency(),"Number of threads for fairness test") | |
static void | burn (size_t n) |
template<typename Lock > | |
static void | runContended (size_t numOps, size_t numThreads) |
template<typename Lock > | |
static void | runFairness () |
template<typename Mutex > | |
void | runUncontended (std::size_t iters) |
BENCHMARK (StdMutexUncontendedBenchmark, iters) | |
BENCHMARK (GoogleSpinUncontendedBenchmark, iters) | |
BENCHMARK (MicroSpinLockUncontendedBenchmark, iters) | |
BENCHMARK (PicoSpinLockUncontendedBenchmark, iters) | |
BENCHMARK (MicroLockUncontendedBenchmark, iters) | |
BENCHMARK (SharedMutexUncontendedBenchmark, iters) | |
BENCHMARK (DistributedMutexUncontendedBenchmark, iters) | |
BENCHMARK (AtomicFetchAddUncontendedBenchmark, iters) | |
__attribute__ ((noinline, noclone)) VirtualBase *makeVirtual() | |
BENCHMARK (VirtualFunctionCall, iters) | |
BENCHMARK_DRAW_LINE () | |
static void | std_mutex (size_t numOps, size_t numThreads) |
static void | google_spin (size_t numOps, size_t numThreads) |
static void | folly_microspin (size_t numOps, size_t numThreads) |
static void | folly_picospin (size_t numOps, size_t numThreads) |
static void | folly_microlock (size_t numOps, size_t numThreads) |
static void | folly_sharedmutex (size_t numOps, size_t numThreads) |
static void | folly_distributedmutex (size_t numOps, size_t numThreads) |
FB_VA_GLUE (BENCHMARK_NAMED_PARAM,(std_mutex, 1thread, 1)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microspin, 1thread, 1)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microlock, 1thread, 1)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_distributedmutex, 1thread, 1)) BENCHMARK_DRAW_LINE() | |
FB_VA_GLUE (BENCHMARK_NAMED_PARAM,(std_mutex, 2thread, 2)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microspin, 2thread, 2)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microlock, 2thread, 2)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_distributedmutex, 2thread, 2)) BENCHMARK_DRAW_LINE() | |
FB_VA_GLUE (BENCHMARK_NAMED_PARAM,(std_mutex, 4thread, 4)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microspin, 4thread, 4)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microlock, 4thread, 4)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_distributedmutex, 4thread, 4)) BENCHMARK_DRAW_LINE() | |
FB_VA_GLUE (BENCHMARK_NAMED_PARAM,(std_mutex, 8thread, 8)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microspin, 8thread, 8)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microlock, 8thread, 8)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_distributedmutex, 8thread, 8)) BENCHMARK_DRAW_LINE() | |
FB_VA_GLUE (BENCHMARK_NAMED_PARAM,(std_mutex, 16thread, 16)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microspin, 16thread, 16)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microlock, 16thread, 16)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_distributedmutex, 16thread, 16)) BENCHMARK_DRAW_LINE() | |
FB_VA_GLUE (BENCHMARK_NAMED_PARAM,(std_mutex, 32thread, 32)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microspin, 32thread, 32)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microlock, 32thread, 32)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_distributedmutex, 32thread, 32)) BENCHMARK_DRAW_LINE() | |
FB_VA_GLUE (BENCHMARK_NAMED_PARAM,(std_mutex, 64thread, 64)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microspin, 64thread, 64)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microlock, 64thread, 64)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_distributedmutex, 64thread, 64)) BENCHMARK_DRAW_LINE() | |
FB_VA_GLUE (BENCHMARK_NAMED_PARAM,(std_mutex, 128thread, 128)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microspin, 128thread, 128)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_microlock, 128thread, 128)) FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM | |
FB_VA_GLUE (BENCHMARK_RELATIVE_NAMED_PARAM,(folly_distributedmutex, 128thread, 128)) int main(int argc | |
runFairness< std::mutex > () | |
runFairness< GoogleSpinLockAdapter > () | |
runFairness< InitLock< folly::MicroSpinLock > > () | |
runFairness< InitLock< folly::PicoSpinLock< uint16_t > > > () | |
runFairness< InitLock< folly::MicroLock > > () | |
runFairness< folly::SharedMutex > () | |
runFairness< folly::DistributedMutex > () | |
Variables | |
google_spin | |
folly_picospin | |
folly_sharedmutex | |
char ** | argv |
return | |
#define BENCH_BASE | ( | ... | ) | FB_VA_GLUE(BENCHMARK_NAMED_PARAM, (__VA_ARGS__)) |
Definition at line 334 of file SmallLocksBenchmark.cpp.
Referenced by folly_distributedmutex().
#define BENCH_REL | ( | ... | ) | FB_VA_GLUE(BENCHMARK_RELATIVE_NAMED_PARAM, (__VA_ARGS__)) |
Definition at line 335 of file SmallLocksBenchmark.cpp.
__attribute__ | ( | (noinline, noclone) | ) |
Definition at line 319 of file SmallLocksBenchmark.cpp.
Referenced by folly::SingletonVault::scheduleDestroyInstances().
BENCHMARK | ( | StdMutexUncontendedBenchmark | , |
iters | |||
) |
Definition at line 272 of file SmallLocksBenchmark.cpp.
BENCHMARK | ( | GoogleSpinUncontendedBenchmark | , |
iters | |||
) |
Definition at line 276 of file SmallLocksBenchmark.cpp.
BENCHMARK | ( | MicroSpinLockUncontendedBenchmark | , |
iters | |||
) |
Definition at line 280 of file SmallLocksBenchmark.cpp.
BENCHMARK | ( | PicoSpinLockUncontendedBenchmark | , |
iters | |||
) |
Definition at line 284 of file SmallLocksBenchmark.cpp.
BENCHMARK | ( | MicroLockUncontendedBenchmark | , |
iters | |||
) |
Definition at line 288 of file SmallLocksBenchmark.cpp.
BENCHMARK | ( | SharedMutexUncontendedBenchmark | , |
iters | |||
) |
Definition at line 292 of file SmallLocksBenchmark.cpp.
BENCHMARK | ( | DistributedMutexUncontendedBenchmark | , |
iters | |||
) |
Definition at line 296 of file SmallLocksBenchmark.cpp.
BENCHMARK | ( | AtomicFetchAddUncontendedBenchmark | , |
iters | |||
) |
Definition at line 300 of file SmallLocksBenchmark.cpp.
References folly::doNotOptimizeAway().
BENCHMARK | ( | VirtualFunctionCall | , |
iters | |||
) |
Definition at line 323 of file SmallLocksBenchmark.cpp.
References BENCHMARK_DRAW_LINE(), and VirtualBase::foo().
BENCHMARK_DRAW_LINE | ( | ) |
Referenced by BENCHMARK(), and folly_distributedmutex().
|
static |
Definition at line 44 of file SmallLocksBenchmark.cpp.
References count, folly::doNotOptimizeAway(), i, folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::lock(), folly::detail::lock(), folly::gen::move, mutex, Mutex, folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::unlock(), and folly::detail::distributed_mutex::wait().
Referenced by runContended(), and runFairness().
DEFINE_int32 | ( | work | , |
100 | , | ||
"Number of work cycles" | |||
) |
DEFINE_int32 | ( | unlocked_work | , |
1000 | , | ||
"Number of unlocked work cycles" | |||
) |
DEFINE_int32 | ( | threads | , |
std::thread::hardware_concurrency() | , | ||
"Number of threads for fairness test" | |||
) |
FB_VA_GLUE | ( | BENCHMARK_NAMED_PARAM | , |
(std_mutex, 1thread, 1) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microspin, 1thread, 1) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microlock, 1thread, 1) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_distributedmutex, 1thread, 1) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_NAMED_PARAM | , |
(std_mutex, 2thread, 2) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microspin, 2thread, 2) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microlock, 2thread, 2) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_distributedmutex, 2thread, 2) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_NAMED_PARAM | , |
(std_mutex, 4thread, 4) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microspin, 4thread, 4) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microlock, 4thread, 4) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_distributedmutex, 4thread, 4) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_NAMED_PARAM | , |
(std_mutex, 8thread, 8) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microspin, 8thread, 8) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microlock, 8thread, 8) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_distributedmutex, 8thread, 8) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_NAMED_PARAM | , |
(std_mutex, 16thread, 16) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microspin, 16thread, 16) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microlock, 16thread, 16) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_distributedmutex, 16thread, 16) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_NAMED_PARAM | , |
(std_mutex, 32thread, 32) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microspin, 32thread, 32) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microlock, 32thread, 32) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_distributedmutex, 32thread, 32) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_NAMED_PARAM | , |
(std_mutex, 64thread, 64) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microspin, 64thread, 64) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microlock, 64thread, 64) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_distributedmutex, 64thread, 64) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_NAMED_PARAM | , |
(std_mutex, 128thread, 128) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microspin, 128thread, 128) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_microlock, 128thread, 128) | |||
) |
FB_VA_GLUE | ( | BENCHMARK_RELATIVE_NAMED_PARAM | , |
(folly_distributedmutex, 128thread, 128) | |||
) |
|
static |
Definition at line 355 of file SmallLocksBenchmark.cpp.
References BENCH_BASE, BENCHMARK_DRAW_LINE(), and std_mutex().
|
static |
Definition at line 349 of file SmallLocksBenchmark.cpp.
|
static |
Definition at line 343 of file SmallLocksBenchmark.cpp.
|
static |
Definition at line 346 of file SmallLocksBenchmark.cpp.
|
static |
Definition at line 352 of file SmallLocksBenchmark.cpp.
|
static |
Definition at line 340 of file SmallLocksBenchmark.cpp.
|
static |
Definition at line 115 of file SmallLocksBenchmark.cpp.
References burn(), folly::BenchmarkSuspender::dismissing(), folly::detail::lock(), folly::ssl::detail::locks(), folly::gen::move, mutex, folly::pushmi::detail::t, threads, and value.
|
static |
Definition at line 161 of file SmallLocksBenchmark.cpp.
References folly::f14::accumulate(), burn(), diff(), for_each(), g(), folly::detail::lock(), folly::ssl::detail::locks(), m, max, folly::gen::move, mutex, now(), folly::detail::rlock(), stop(), sum(), folly::pushmi::detail::t, threads, folly::detail::distributed_mutex::time(), and value.
runFairness< folly::SharedMutex > | ( | ) |
runFairness< GoogleSpinLockAdapter > | ( | ) |
runFairness< InitLock< folly::MicroLock > > | ( | ) |
runFairness< InitLock< folly::MicroSpinLock > > | ( | ) |
runFairness< InitLock< folly::PicoSpinLock< uint16_t > > > | ( | ) |
runFairness< std::mutex > | ( | ) |
void runUncontended | ( | std::size_t | iters | ) |
Definition at line 264 of file SmallLocksBenchmark.cpp.
References i, folly::detail::lock(), folly::gen::move, mutex, and Mutex.
|
static |
Definition at line 337 of file SmallLocksBenchmark.cpp.
Referenced by folly_distributedmutex().
char** argv |
Definition at line 430 of file SmallLocksBenchmark.cpp.
Referenced by testing::AddGlobalTestEnvironment(), testing::internal::GetUnitTestImpl(), folly::NestedCommandLineApp::globalOptions(), testing::UnitTest::impl(), main(), testing::internal::ParseGoogleMockStringFlag(), testing::internal::UnitTestImpl::set_catch_exceptions(), folly::Subprocess::spawn(), folly::Subprocess::Subprocess(), TEST(), testing::TEST_F(), and TestInitGoogleMock().
folly_picospin |
Definition at line 363 of file SmallLocksBenchmark.cpp.
folly_sharedmutex |
Definition at line 365 of file SmallLocksBenchmark.cpp.
google_spin |
Definition at line 361 of file SmallLocksBenchmark.cpp.
return |
Definition at line 443 of file SmallLocksBenchmark.cpp.