Skip to content

Commit d1432ef

Browse files
authored
chore(tiering): Make lower bound configurable (#5810)
1 parent 7787d41 commit d1432ef

File tree

8 files changed

+27
-39
lines changed

8 files changed

+27
-39
lines changed

helio

src/facade/dragonfly_connection.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <variant>
1515

1616
#include "base/cycle_clock.h"
17+
#include "base/flag_utils.h"
1718
#include "base/flags.h"
1819
#include "base/histogram.h"
1920
#include "base/io_buf.h"
@@ -22,7 +23,6 @@
2223
#include "core/heap_size.h"
2324
#include "facade/conn_context.h"
2425
#include "facade/dragonfly_listener.h"
25-
#include "facade/flag_utils.h"
2626
#include "facade/memcache_parser.h"
2727
#include "facade/redis_parser.h"
2828
#include "facade/service_interface.h"
@@ -2178,9 +2178,9 @@ void Connection::UpdateFromFlags() {
21782178
}
21792179

21802180
std::vector<std::string> Connection::GetMutableFlagNames() {
2181-
return GetFlagNames(FLAGS_pipeline_queue_limit, FLAGS_pipeline_buffer_limit,
2182-
FLAGS_max_busy_read_usec, FLAGS_always_flush_pipeline,
2183-
FLAGS_pipeline_squash_limit, FLAGS_pipeline_wait_batch_usec);
2181+
return base::GetFlagNames(FLAGS_pipeline_queue_limit, FLAGS_pipeline_buffer_limit,
2182+
FLAGS_max_busy_read_usec, FLAGS_always_flush_pipeline,
2183+
FLAGS_pipeline_squash_limit, FLAGS_pipeline_wait_batch_usec);
21842184
}
21852185

21862186
void Connection::GetRequestSizeHistogramThreadLocal(std::string* hist) {

src/facade/flag_utils.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/server/main_service.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ extern "C" {
3131
#include <filesystem>
3232

3333
#include "base/cycle_clock.h"
34+
#include "base/flag_utils.h"
3435
#include "base/flags.h"
3536
#include "base/logging.h"
3637
#include "facade/dragonfly_connection.h"
3738
#include "facade/error.h"
38-
#include "facade/flag_utils.h"
3939
#include "facade/reply_builder.h"
4040
#include "facade/reply_capture.h"
4141
#include "server/acl/acl_commands_def.h"
@@ -742,8 +742,8 @@ void UpdateFromFlagsOnThread() {
742742
}
743743

744744
std::vector<std::string> GetMutableFlagNames() {
745-
return facade::GetFlagNames(FLAGS_shard_thread_busy_polling_usec,
746-
FLAGS_squash_stats_latency_lower_limit);
745+
return base::GetFlagNames(FLAGS_shard_thread_busy_polling_usec,
746+
FLAGS_squash_stats_latency_lower_limit);
747747
}
748748

749749
void UpdateUringFlagsOnThread() {
@@ -951,13 +951,13 @@ void Service::Init(util::AcceptServer* acceptor, std::vector<facade::Listener*>
951951
[]() { MultiCommandSquasher::UpdateFromFlags(); });
952952
// Register uring proactor flags
953953
RegisterMutableFlags(&config_registry,
954-
facade::GetFlagNames(FLAGS_uring_wake_mode, FLAGS_uring_submit_threshold),
954+
base::GetFlagNames(FLAGS_uring_wake_mode, FLAGS_uring_submit_threshold),
955955
[]() { UpdateUringFlagsOnThread(); });
956956
// Register scheduler flags
957957
RegisterMutableFlags(
958958
&config_registry,
959-
facade::GetFlagNames(FLAGS_scheduler_background_budget, FLAGS_scheduler_background_sleep_prob,
960-
FLAGS_scheduler_background_warrant),
959+
base::GetFlagNames(FLAGS_scheduler_background_budget, FLAGS_scheduler_background_sleep_prob,
960+
FLAGS_scheduler_background_warrant),
961961
[]() { UpdateSchedulerFlagsOnThread(); });
962962

963963
config_registry.RegisterSetter<MemoryBytesFlag>("maxmemory", [](const MemoryBytesFlag& flag) {

src/server/multi_command_squasher.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#include <absl/container/inlined_vector.h>
88

99
#include "base/cycle_clock.h"
10+
#include "base/flag_utils.h"
1011
#include "base/flags.h"
1112
#include "base/logging.h"
1213
#include "core/overloaded.h"
1314
#include "facade/dragonfly_connection.h"
14-
#include "facade/flag_utils.h"
1515
#include "server/command_registry.h"
1616
#include "server/conn_context.h"
1717
#include "server/engine_shard_set.h"
@@ -426,7 +426,7 @@ void MultiCommandSquasher::UpdateFromFlags() {
426426
}
427427

428428
vector<string> MultiCommandSquasher::GetMutableFlagNames() {
429-
return facade::GetFlagNames(FLAGS_max_busy_squash_usec, FLAGS_log_squash_info_threshold_usec);
429+
return base::GetFlagNames(FLAGS_max_busy_squash_usec, FLAGS_log_squash_info_threshold_usec);
430430
}
431431

432432
} // namespace dfly

src/server/server_state.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ extern "C" {
1212
#include "redis/zmalloc.h"
1313
}
1414

15+
#include "base/flag_utils.h"
1516
#include "base/flags.h"
1617
#include "base/logging.h"
1718
#include "facade/conn_context.h"
1819
#include "facade/dragonfly_connection.h"
19-
#include "facade/flag_utils.h"
2020
#include "server/channel_store.h"
2121
#include "server/journal/journal.h"
2222
#include "util/listener_interface.h"
@@ -237,8 +237,8 @@ void ServerState::UpdateFromFlags() {
237237
}
238238

239239
vector<string> ServerState::GetMutableFlagNames() {
240-
return facade::GetFlagNames(FLAGS_rss_oom_deny_ratio, FLAGS_serialization_max_chunk_size,
241-
FLAGS_max_squashed_cmd_num);
240+
return base::GetFlagNames(FLAGS_rss_oom_deny_ratio, FLAGS_serialization_max_chunk_size,
241+
FLAGS_max_squashed_cmd_num);
242242
}
243243

244244
Interpreter* ServerState::BorrowInterpreter() {

src/server/tiered_storage.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
#include "absl/cleanup/cleanup.h"
1616
#include "absl/flags/internal/flag.h"
17+
#include "base/flag_utils.h"
1718
#include "base/flags.h"
1819
#include "base/logging.h"
19-
#include "facade/flag_utils.h"
2020
#include "server/common.h"
2121
#include "server/db_slice.h"
2222
#include "server/engine_shard_set.h"
@@ -29,6 +29,10 @@
2929

3030
using namespace facade;
3131

32+
using AtLeast64 = base::ConstrainedNumericFlagValue<size_t, 64>; // ABSL_FLAG breaks with commas
33+
ABSL_FLAG(AtLeast64, tiered_min_value_size, 64,
34+
"Minimum size of values eligible for offloading. Must be at least 64");
35+
3236
ABSL_FLAG(bool, tiered_experimental_cooling, true,
3337
"If true, uses intermediate cooling layer "
3438
"when offloading values to storage");
@@ -467,6 +471,7 @@ float TieredStorage::WriteDepthUsage() const {
467471

468472
void TieredStorage::UpdateFromFlags() {
469473
config_ = {
474+
.min_value_size = absl::GetFlag(FLAGS_tiered_min_value_size),
470475
.experimental_cooling = absl::GetFlag(FLAGS_tiered_experimental_cooling),
471476
.write_depth_limit = absl::GetFlag(FLAGS_tiered_storage_write_depth),
472477
.offload_threshold = absl::GetFlag(FLAGS_tiered_offload_threshold),
@@ -475,8 +480,9 @@ void TieredStorage::UpdateFromFlags() {
475480
}
476481

477482
std::vector<std::string> TieredStorage::GetMutableFlagNames() {
478-
return facade::GetFlagNames(FLAGS_tiered_experimental_cooling, FLAGS_tiered_storage_write_depth,
479-
FLAGS_tiered_offload_threshold, FLAGS_tiered_upload_threshold);
483+
return base::GetFlagNames(FLAGS_tiered_min_value_size, FLAGS_tiered_experimental_cooling,
484+
FLAGS_tiered_storage_write_depth, FLAGS_tiered_offload_threshold,
485+
FLAGS_tiered_upload_threshold);
480486
}
481487

482488
bool TieredStorage::ShouldOffload() const {
@@ -564,7 +570,7 @@ size_t TieredStorage::ReclaimMemory(size_t goal) {
564570
bool TieredStorage::ShouldStash(const PrimeValue& pv) const {
565571
const auto& disk_stats = op_manager_->GetStats().disk_stats;
566572
return !pv.IsExternal() && !pv.HasStashPending() && pv.ObjType() == OBJ_STRING &&
567-
pv.Size() >= kMinValueSize &&
573+
pv.Size() >= config_.min_value_size &&
568574
disk_stats.allocated_bytes + tiering::kPageSize + pv.Size() < disk_stats.max_file_size;
569575
}
570576

src/server/tiered_storage.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class TieredStorage {
3131
class ShardOpManager;
3232

3333
public:
34-
const static size_t kMinValueSize = 64;
35-
3634
// Min sizes of values taking up full page on their own
3735
const static size_t kMinOccupancySize = tiering::kPageSize / 2;
3836

@@ -114,6 +112,7 @@ class TieredStorage {
114112
CoolQueue cool_queue_;
115113

116114
struct {
115+
size_t min_value_size;
117116
bool experimental_cooling;
118117
unsigned write_depth_limit;
119118
float offload_threshold;
@@ -140,8 +139,6 @@ class TieredStorage {
140139
class ShardOpManager;
141140

142141
public:
143-
const static size_t kMinValueSize = 64;
144-
145142
// Min sizes of values taking up full page on their own
146143
const static size_t kMinOccupancySize = tiering::kPageSize / 2;
147144

0 commit comments

Comments
 (0)