Skip to content

Commit b5512c1

Browse files
committed
1
1 parent 45e4162 commit b5512c1

1 file changed

Lines changed: 21 additions & 60 deletions

File tree

‎cloud/test/recycler_benchmark_test.cpp‎

Lines changed: 21 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <algorithm>
2525
#include <atomic>
2626
#include <chrono>
27-
#include <cmath>
2827
#include <cstddef>
2928
#include <cstdint>
3029
#include <cstdlib>
@@ -57,7 +56,6 @@ namespace {
5756

5857
const std::string kBenchmarkInstanceId = "recycler_benchmark_instance";
5958
const std::string kBenchmarkResourceId = "recycler_benchmark_resource";
60-
double recycler_benchmark_duration_tolerance_ratio = 0.8;
6159

6260
std::string get_env(const char* name) {
6361
const char* value = std::getenv(name);
@@ -112,7 +110,7 @@ void set_obj_store_provider(const std::string& provider, ObjectStoreInfoPB* obj_
112110
}
113111

114112
// Number of recyclable rowsets seeded per branch.
115-
constexpr int64_t kRowsetsPerBranch = 10000;
113+
constexpr int64_t kRowsetsPerBranch = 5000;
116114
// Commit the seeded recycle rowset KVs in batches to keep each txn small.
117115
constexpr int64_t kSeedCommitBatch = 2000;
118116
constexpr int64_t kRowsetsPerPackedFile = 2;
@@ -478,14 +476,6 @@ class RecyclerBenchmarkTest : public ::testing::Test {
478476
old_force_immediate_recycle_ = config::force_immediate_recycle;
479477
old_retention_seconds_ = config::retention_seconds;
480478

481-
const auto tolerance_env = get_env("recycler_benchmark_duration_tolerance_ratio");
482-
size_t parsed_size = 0;
483-
recycler_benchmark_duration_tolerance_ratio =
484-
tolerance_env.empty() ? 0.8 : std::stod(tolerance_env, &parsed_size);
485-
ASSERT_EQ(parsed_size, tolerance_env.size()) << "invalid recycler benchmark tolerance";
486-
ASSERT_TRUE(std::isfinite(recycler_benchmark_duration_tolerance_ratio));
487-
ASSERT_GE(recycler_benchmark_duration_tolerance_ratio, 0);
488-
489479
config::force_immediate_recycle = true;
490480
config::retention_seconds = 0;
491481

@@ -670,15 +660,6 @@ class RecyclerBenchmarkTest : public ::testing::Test {
670660
.del = g_bvar_txn_kv_remove.count() + g_bvar_txn_kv_range_remove.count()};
671661
}
672662

673-
void check_elapsed_ms(const std::string& branch, double actual_ms, double baseline_ms) {
674-
const double limit_ms = baseline_ms * (1 + recycler_benchmark_duration_tolerance_ratio);
675-
if (actual_ms > limit_ms) {
676-
benchmark_failures_ +=
677-
fmt::format("branch={} actual_ms={:.2f} baseline_ms={:.2f} limit_ms={:.2f}\n",
678-
branch, actual_ms, baseline_ms, limit_ms);
679-
}
680-
}
681-
682663
void check_txn_kv_counts(const std::string& branch, const TxnKvCounts& actual,
683664
const TxnKvCounts& baseline) {
684665
if (actual.get != baseline.get || actual.put != baseline.put ||
@@ -1012,57 +993,37 @@ TEST_F(RecyclerBenchmarkTest, RecycleRowsets) {
1012993
ASSERT_EQ(count_recycle_rowsets(), 0);
1013994
});
1014995

1015-
// Recorded with 10,000 rowsets per branch. Recalibrate if the workload changes.
1016-
static_assert(kRowsetsPerBranch == 10000);
1017-
const std::map<std::string, double> baseline_elapsed_ms = {
1018-
{"compacted_empty", 794.18},
1019-
{"compacted_with_data/data_only", 2285.80},
1020-
{"compacted_with_data/delete_bitmap_v1", 2461.84},
1021-
{"compacted_with_data/delete_bitmap_v2", 2726.75},
1022-
{"compacted_with_packed_data/data_only", 8583.32},
1023-
{"compacted_with_packed_data/delete_bitmap_v1", 9315.59},
1024-
{"compacted_with_packed_data/delete_bitmap_v2", 8948.54},
1025-
{"compacted_without_schema", 3924.04},
1026-
{"legacy_empty_resource", 945.75},
1027-
{"legacy_with_resource", 6718.37},
1028-
{"mixed", 35178.52},
1029-
{"prepare_abort", 16465.44},
1030-
{"prepare_direct", 5360.28},
1031-
{"prepare_mark", 7039.65},
1032-
};
996+
// Recorded with 5,000 rowsets per branch. Recalibrate if the workload changes.
997+
static_assert(kRowsetsPerBranch == 5000);
1033998
const std::map<std::string, TxnKvCounts> baseline_txn_kv_counts = {
1034-
{"compacted_empty", {.get = 10000, .put = 0, .del = 10000}},
1035-
{"compacted_with_data/data_only", {.get = 10001, .put = 0, .del = 10000}},
1036-
{"compacted_with_data/delete_bitmap_v1", {.get = 10000, .put = 0, .del = 10000}},
1037-
{"compacted_with_data/delete_bitmap_v2", {.get = 20000, .put = 0, .del = 20000}},
1038-
{"compacted_with_packed_data/data_only", {.get = 25000, .put = 10000, .del = 15000}},
999+
{"compacted_empty", {.get = 5000, .put = 0, .del = 5000}},
1000+
// First schema cache fill reads one KV in addition to the 5,000 rowset KVs.
1001+
{"compacted_with_data/data_only", {.get = 5001, .put = 0, .del = 5000}},
1002+
{"compacted_with_data/delete_bitmap_v1", {.get = 5000, .put = 0, .del = 5000}},
1003+
{"compacted_with_data/delete_bitmap_v2", {.get = 10000, .put = 0, .del = 10000}},
1004+
{"compacted_with_packed_data/data_only", {.get = 12500, .put = 5000, .del = 7500}},
10391005
{"compacted_with_packed_data/delete_bitmap_v1",
1040-
{.get = 25000, .put = 10000, .del = 15000}},
1006+
{.get = 12500, .put = 5000, .del = 7500}},
10411007
{"compacted_with_packed_data/delete_bitmap_v2",
1042-
{.get = 35000, .put = 10000, .del = 25000}},
1043-
{"compacted_without_schema", {.get = 10000, .put = 0, .del = 10000}},
1044-
{"legacy_empty_resource", {.get = 10000, .put = 0, .del = 10000}},
1045-
{"legacy_with_resource", {.get = 20000, .put = 0, .del = 20000}},
1046-
{"mixed", {.get = 200000, .put = 40000, .del = 120000}},
1047-
{"prepare_abort", {.get = 90000, .put = 30000, .del = 30000}},
1048-
{"prepare_direct", {.get = 20000, .put = 0, .del = 20000}},
1049-
{"prepare_mark", {.get = 40000, .put = 10000, .del = 20000}},
1008+
{.get = 17500, .put = 5000, .del = 12500}},
1009+
{"compacted_without_schema", {.get = 5000, .put = 0, .del = 5000}},
1010+
{"legacy_empty_resource", {.get = 5000, .put = 0, .del = 5000}},
1011+
{"legacy_with_resource", {.get = 10000, .put = 0, .del = 10000}},
1012+
{"mixed", {.get = 100000, .put = 20000, .del = 60000}},
1013+
{"prepare_abort", {.get = 45000, .put = 15000, .del = 15000}},
1014+
{"prepare_direct", {.get = 10000, .put = 0, .del = 10000}},
1015+
{"prepare_mark", {.get = 20000, .put = 5000, .del = 10000}},
10501016
};
10511017
const auto& results = benchmark_results_["recycle_rowsets"];
1052-
double total_elapsed_ms = 0;
1053-
for (const auto& [branch, baseline_ms] : baseline_elapsed_ms) {
1018+
for (const auto& [branch, baseline_counts] : baseline_txn_kv_counts) {
10541019
const auto result = results.find(branch);
10551020
if (result == results.end()) {
10561021
benchmark_failures_ +=
1057-
fmt::format("branch={} did not produce a timing result\n", branch);
1022+
fmt::format("branch={} did not produce a benchmark result\n", branch);
10581023
continue;
10591024
}
1060-
check_elapsed_ms(branch, result->second.elapsed_ms, baseline_ms);
1061-
check_txn_kv_counts(branch, result->second.txn_kv_counts,
1062-
baseline_txn_kv_counts.at(branch));
1063-
total_elapsed_ms += result->second.elapsed_ms;
1025+
check_txn_kv_counts(branch, result->second.txn_kv_counts, baseline_counts);
10641026
}
1065-
check_elapsed_ms("total_elapsed_ms", total_elapsed_ms, 110748.07);
10661027
}
10671028

10681029
} // namespace

0 commit comments

Comments
 (0)