From a45aa2af51ba5a42ca7cb7409ee211ad3e656e66 Mon Sep 17 00:00:00 2001 From: Peizhao Ou Date: Wed, 7 Feb 2018 15:19:04 -0800 Subject: [PATCH] Refactors RCU test cases --- folly/stress-test/clean.sh | 6 ++++- .../stress-sequential-folly-sync.cpp | 22 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/folly/stress-test/clean.sh b/folly/stress-test/clean.sh index 8144dba8..19a24e70 100755 --- a/folly/stress-test/clean.sh +++ b/folly/stress-test/clean.sh @@ -1,6 +1,10 @@ #!/bin/bash -e -Benchmarks=(stress-sequential-folly-map) +Benchmarks=( + stress-sequential-folly-queue + stress-sequential-folly-map + stress-sequential-folly-sync +) for bench in ${Benchmarks[*]}; do rm -rf $bench ${bench}.bc ${bench}.o diff --git a/folly/stress-test/stress-sequential-folly-sync.cpp b/folly/stress-test/stress-sequential-folly-sync.cpp index 0b849c50..dbedef05 100644 --- a/folly/stress-test/stress-sequential-folly-sync.cpp +++ b/folly/stress-test/stress-sequential-folly-sync.cpp @@ -49,8 +49,8 @@ typedef folly::RWTicketSpinLock32 RWTicketSpinLock32; typedef folly::RWTicketSpinLock64 RWTicketSpinLock64; // RCU -const size_t kRcuSyncPassCount = 3000000; -const size_t kRcuNoSyncPassCount = 2500000; +const size_t kRcuSyncPassCount = 180000; +const size_t kRcuNoSyncPassCount = 3500000; const char* kRcuSyncBenchmarkName = "FollyRCU_Sync"; const char* kRcuNoSyncBenchmarkName = "FollyRCU_NoSync"; // Represent the RCU-protected data. @@ -65,10 +65,18 @@ void run_rcu_sync(size_t pass_count, const char* bench_name) { std::cout << "[ RUN ] " << kTestName << "." << bench_name << std::endl; auto start_time = std::chrono::system_clock::now(); - for (size_t count = 0; count < pass_count; count++) { - RcuFoo* f = new RcuFoo(); - folly::rcu_retire(f); - folly::synchronize_rcu(); + for (int write_percentage = 1; write_percentage <= 5; write_percentage += 1) { + for (size_t count = 0; count < pass_count; count++) { + for (int i = 0; i < 100; ++i) { + if (i < write_percentage) { + RcuFoo* f = new RcuFoo(); + folly::rcu_retire(f); + folly::synchronize_rcu(); + } else { + folly::rcu_reader g; + } + } + } } auto finish_time = std::chrono::system_clock::now(); @@ -82,7 +90,7 @@ void run_rcu_no_sync(size_t pass_count, const char* bench_name) { std::cout << "[ RUN ] " << kTestName << "." << bench_name << std::endl; auto start_time = std::chrono::system_clock::now(); - for (int write_percentage = 5; write_percentage <= 10; write_percentage += 1) { + for (int write_percentage = 1; write_percentage <= 5; write_percentage += 1) { for (size_t count = 0; count < pass_count; count++) { for (int i = 0; i < 100; ++i) { if (i < write_percentage) { -- 2.34.1