|
24 | 24 | #include <algorithm> |
25 | 25 | #include <atomic> |
26 | 26 | #include <chrono> |
27 | | -#include <cmath> |
28 | 27 | #include <cstddef> |
29 | 28 | #include <cstdint> |
30 | 29 | #include <cstdlib> |
@@ -57,7 +56,6 @@ namespace { |
57 | 56 |
|
58 | 57 | const std::string kBenchmarkInstanceId = "recycler_benchmark_instance"; |
59 | 58 | const std::string kBenchmarkResourceId = "recycler_benchmark_resource"; |
60 | | -double recycler_benchmark_duration_tolerance_ratio = 0.8; |
61 | 59 |
|
62 | 60 | std::string get_env(const char* name) { |
63 | 61 | const char* value = std::getenv(name); |
@@ -112,7 +110,7 @@ void set_obj_store_provider(const std::string& provider, ObjectStoreInfoPB* obj_ |
112 | 110 | } |
113 | 111 |
|
114 | 112 | // Number of recyclable rowsets seeded per branch. |
115 | | -constexpr int64_t kRowsetsPerBranch = 10000; |
| 113 | +constexpr int64_t kRowsetsPerBranch = 5000; |
116 | 114 | // Commit the seeded recycle rowset KVs in batches to keep each txn small. |
117 | 115 | constexpr int64_t kSeedCommitBatch = 2000; |
118 | 116 | constexpr int64_t kRowsetsPerPackedFile = 2; |
@@ -478,14 +476,6 @@ class RecyclerBenchmarkTest : public ::testing::Test { |
478 | 476 | old_force_immediate_recycle_ = config::force_immediate_recycle; |
479 | 477 | old_retention_seconds_ = config::retention_seconds; |
480 | 478 |
|
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 | | - |
489 | 479 | config::force_immediate_recycle = true; |
490 | 480 | config::retention_seconds = 0; |
491 | 481 |
|
@@ -670,15 +660,6 @@ class RecyclerBenchmarkTest : public ::testing::Test { |
670 | 660 | .del = g_bvar_txn_kv_remove.count() + g_bvar_txn_kv_range_remove.count()}; |
671 | 661 | } |
672 | 662 |
|
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 | | - |
682 | 663 | void check_txn_kv_counts(const std::string& branch, const TxnKvCounts& actual, |
683 | 664 | const TxnKvCounts& baseline) { |
684 | 665 | if (actual.get != baseline.get || actual.put != baseline.put || |
@@ -1012,57 +993,37 @@ TEST_F(RecyclerBenchmarkTest, RecycleRowsets) { |
1012 | 993 | ASSERT_EQ(count_recycle_rowsets(), 0); |
1013 | 994 | }); |
1014 | 995 |
|
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); |
1033 | 998 | 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}}, |
1039 | 1005 | {"compacted_with_packed_data/delete_bitmap_v1", |
1040 | | - {.get = 25000, .put = 10000, .del = 15000}}, |
| 1006 | + {.get = 12500, .put = 5000, .del = 7500}}, |
1041 | 1007 | {"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}}, |
1050 | 1016 | }; |
1051 | 1017 | 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) { |
1054 | 1019 | const auto result = results.find(branch); |
1055 | 1020 | if (result == results.end()) { |
1056 | 1021 | 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); |
1058 | 1023 | continue; |
1059 | 1024 | } |
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); |
1064 | 1026 | } |
1065 | | - check_elapsed_ms("total_elapsed_ms", total_elapsed_ms, 110748.07); |
1066 | 1027 | } |
1067 | 1028 |
|
1068 | 1029 | } // namespace |
|
0 commit comments