proxygen
|
#include <folly/ThreadCachedInt.h>
#include <atomic>
#include <condition_variable>
#include <memory>
#include <thread>
#include <glog/logging.h>
#include <folly/Benchmark.h>
#include <folly/hash/Hash.h>
#include <folly/portability/GFlags.h>
#include <folly/portability/GTest.h>
#include <folly/system/ThreadId.h>
Go to the source code of this file.
Classes | |
class | ThreadCachedIntTest |
struct | ShardedAtomicInt |
Macros | |
#define | CREATE_INC_FUNC(size) |
#define | MAKE_MT_CACHE_SIZE_BM(size) |
#define | REG_BASELINE(name, inc_stmt) |
Typedefs | |
using | Counter = ThreadCachedInt< int64_t > |
Functions | |
TEST_F (ThreadCachedIntTest, MultithreadedSlow) | |
TEST_F (ThreadCachedIntTest, MultithreadedFast) | |
TEST (ThreadCachedInt, SingleThreadedNotCached) | |
TEST (ThreadCachedInt, SingleThreadedCached) | |
DEFINE_int32 (numThreads, 8,"Number simultaneous threads for benchmarks.") | |
void | incFunc64 () |
void | incFunc32 () |
TEST (ThreadCachedInt, MultiThreadedCached) | |
void | BM_mt_cache_size64 (int iters, int cacheSize) |
void | BM_mt_cache_size32 (int iters, int cacheSize) |
std::atomic< int64_t > | globalInt64Baseline (0) |
std::atomic< int32_t > | globalInt32Baseline (0) |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, _thread64), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, _thread32), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, ThreadLocal64), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, ThreadLocal32), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, atomic_inc64), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, atomic_inc32), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, ShardedAtm64), iters) | |
BENCHMARK_DRAW_LINE () | |
BENCHMARK (Atomic_readFull) | |
BENCHMARK (ThrCache_readFull) | |
BENCHMARK (Sharded_readFull) | |
BENCHMARK (ThrCache_readFast) | |
BENCHMARK (Sharded_readFast) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, Atomic_readFull), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, ThrCache_readFull), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, Sharded_readFull), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, ThrCache_readFast), iters) | |
BENCHMARK (FB_CONCATENATE(BM_mt_baseline_, Sharded_readFast), iters) | |
int | main (int argc, char **argv) |
Variables | |
ThreadCachedInt< int32_t > | globalInt32 (0, 11) |
ThreadCachedInt< int64_t > | globalInt64 (0, 11) |
int | kNumInserts = 100000 |
ThreadLocal< int64_t > | globalTL64Baseline |
ThreadLocal< int32_t > | globalTL32Baseline |
FOLLY_TLS int64_t | global__thread64 |
FOLLY_TLS int32_t | global__thread32 |
ShardedAtomicInt | shd_int64 |
#define CREATE_INC_FUNC | ( | size | ) |
Definition at line 204 of file ThreadCachedIntTest.cpp.
#define MAKE_MT_CACHE_SIZE_BM | ( | size | ) |
Definition at line 262 of file ThreadCachedIntTest.cpp.
#define REG_BASELINE | ( | name, | |
inc_stmt | |||
) |
Definition at line 278 of file ThreadCachedIntTest.cpp.
Referenced by BENCHMARK().
using Counter = ThreadCachedInt<int64_t> |
Definition at line 37 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,_thread64) | , |
iters | |||
) |
Definition at line 335 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,_thread32) | , |
iters | |||
) |
Definition at line 336 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,ThreadLocal64) | , |
iters | |||
) |
Definition at line 337 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,ThreadLocal32) | , |
iters | |||
) |
Definition at line 338 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,atomic_inc64) | , |
iters | |||
) |
Definition at line 341 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,atomic_inc32) | , |
iters | |||
) |
Definition at line 344 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,ShardedAtm64) | , |
iters | |||
) |
Definition at line 345 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | Atomic_readFull | ) |
Definition at line 358 of file ThreadCachedIntTest.cpp.
References folly::doNotOptimizeAway().
BENCHMARK | ( | ThrCache_readFull | ) |
Definition at line 361 of file ThreadCachedIntTest.cpp.
References folly::doNotOptimizeAway(), and folly::ThreadCachedInt< IntT, Tag >::readFull().
BENCHMARK | ( | Sharded_readFull | ) |
Definition at line 364 of file ThreadCachedIntTest.cpp.
References folly::doNotOptimizeAway(), and ShardedAtomicInt::readFull().
BENCHMARK | ( | ThrCache_readFast | ) |
Definition at line 367 of file ThreadCachedIntTest.cpp.
References folly::doNotOptimizeAway(), and folly::ThreadCachedInt< IntT, Tag >::readFast().
BENCHMARK | ( | Sharded_readFast | ) |
Definition at line 370 of file ThreadCachedIntTest.cpp.
References folly::BENCHMARK_DRAW_LINE(), folly::doNotOptimizeAway(), ShardedAtomicInt::readFast(), and REG_BASELINE.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,Atomic_readFull) | , |
iters | |||
) |
Definition at line 378 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,ThrCache_readFull) | , |
iters | |||
) |
Definition at line 379 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,Sharded_readFull) | , |
iters | |||
) |
Definition at line 380 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,ThrCache_readFast) | , |
iters | |||
) |
Definition at line 381 of file ThreadCachedIntTest.cpp.
BENCHMARK | ( | FB_CONCATENATE(BM_mt_baseline_,Sharded_readFast) | , |
iters | |||
) |
Definition at line 382 of file ThreadCachedIntTest.cpp.
BENCHMARK_DRAW_LINE | ( | ) |
void BM_mt_cache_size32 | ( | int | iters, |
int | cacheSize | ||
) |
Definition at line 276 of file ThreadCachedIntTest.cpp.
void BM_mt_cache_size64 | ( | int | iters, |
int | cacheSize | ||
) |
Definition at line 275 of file ThreadCachedIntTest.cpp.
DEFINE_int32 | ( | numThreads | , |
8 | , | ||
"Number simultaneous threads for benchmarks." | |||
) |
std::atomic<int32_t> globalInt32Baseline | ( | 0 | ) |
std::atomic<int64_t> globalInt64Baseline | ( | 0 | ) |
void incFunc32 | ( | ) |
Definition at line 212 of file ThreadCachedIntTest.cpp.
void incFunc64 | ( | ) |
Definition at line 211 of file ThreadCachedIntTest.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 385 of file ThreadCachedIntTest.cpp.
References testing::InitGoogleTest(), RUN_ALL_TESTS(), and folly::runBenchmarks().
TEST | ( | ThreadCachedInt | , |
SingleThreadedNotCached | |||
) |
Definition at line 169 of file ThreadCachedIntTest.cpp.
References EXPECT_EQ, i, folly::ThreadCachedInt< IntT, Tag >::readFast(), and val.
TEST | ( | ThreadCachedInt | , |
SingleThreadedCached | |||
) |
Definition at line 184 of file ThreadCachedIntTest.cpp.
References EXPECT_EQ, globalInt32, globalInt64, i, folly::ThreadCachedInt< IntT, Tag >::readFast(), and val.
TEST | ( | ThreadCachedInt | , |
MultiThreadedCached | |||
) |
Definition at line 215 of file ThreadCachedIntTest.cpp.
References EXPECT_EQ, EXPECT_NE, FOR_EACH_RANGE, i, k, kNumInserts, folly::ThreadCachedInt< IntT, Tag >::readFast(), folly::ThreadCachedInt< IntT, Tag >::readFull(), folly::run(), folly::ThreadCachedInt< IntT, Tag >::set(), folly::pushmi::detail::t, and threads.
TEST_F | ( | ThreadCachedIntTest | , |
MultithreadedSlow | |||
) |
Definition at line 81 of file ThreadCachedIntTest.cpp.
References EXPECT_EQ, EXPECT_GE, i, int32_t, kNumThreads, threads, and uint32_t.
TEST_F | ( | ThreadCachedIntTest | , |
MultithreadedFast | |||
) |
Definition at line 137 of file ThreadCachedIntTest.cpp.
References EXPECT_EQ, i, int32_t, kNumThreads, threads, and uint32_t.
FOLLY_TLS int32_t global__thread32 |
Definition at line 299 of file ThreadCachedIntTest.cpp.
FOLLY_TLS int64_t global__thread64 |
Definition at line 298 of file ThreadCachedIntTest.cpp.
ThreadCachedInt<int32_t> globalInt32(0, 11) |
Referenced by TEST().
ThreadCachedInt<int64_t> globalInt64(0, 11) |
Referenced by TEST().
ThreadLocal<int32_t> globalTL32Baseline |
Definition at line 295 of file ThreadCachedIntTest.cpp.
ThreadLocal<int64_t> globalTL64Baseline |
Definition at line 294 of file ThreadCachedIntTest.cpp.
int kNumInserts = 100000 |
Definition at line 202 of file ThreadCachedIntTest.cpp.
Referenced by TEST().
ShardedAtomicInt shd_int64 |
Definition at line 333 of file ThreadCachedIntTest.cpp.