Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,8 @@ void PrestoServer::initializeVeloxMemory() {
systemConfig->asyncCacheMaxSsdWriteRatio(),
systemConfig->asyncCacheSsdSavableRatio(),
systemConfig->asyncCacheMinSsdSavableBytes(),
systemConfig->asyncCacheNumShards()};
systemConfig->asyncCacheNumShards(),
systemConfig->asyncCacheSsdFlushThresholdBytes()};
cache_ = velox::cache::AsyncDataCache::create(
velox::memory::memoryManager()->allocator(),
std::move(ssd),
Expand Down
5 changes: 5 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ SystemConfig::SystemConfig() {
NUM_PROP(kAsyncCacheSsdSavableRatio, 0.125),
NUM_PROP(kAsyncCacheMinSsdSavableBytes, 1 << 24 /*16MB*/),
NUM_PROP(kAsyncCacheNumShards, 4),
NUM_PROP(kAsyncCacheSsdFlushThresholdBytes, 0),
STR_PROP(kAsyncCachePersistenceInterval, "0s"),
BOOL_PROP(kAsyncCacheSsdDisableFileCow, false),
BOOL_PROP(kSsdCacheChecksumEnabled, false),
Expand Down Expand Up @@ -719,6 +720,10 @@ int32_t SystemConfig::asyncCacheNumShards() const {
return optionalProperty<int32_t>(kAsyncCacheNumShards).value();
}

uint64_t SystemConfig::asyncCacheSsdFlushThresholdBytes() const {
return optionalProperty<uint64_t>(kAsyncCacheSsdFlushThresholdBytes).value();
}

std::chrono::duration<double> SystemConfig::asyncCachePersistenceInterval()
const {
return velox::config::toDuration(
Expand Down
8 changes: 8 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ class SystemConfig : public ConfigBase {
static constexpr std::string_view kAsyncCacheNumShards{
"async-cache-num-shards"};

/// The maximum threshold in bytes for triggering SSD flush. When the
/// accumulated SSD-savable bytes exceed this value, a flush to SSD is
/// triggered. Set to 0 to disable this threshold (default).
static constexpr std::string_view kAsyncCacheSsdFlushThresholdBytes{
"async-cache-ssd-flush-threshold-bytes"};

/// The interval for persisting in-memory cache to SSD. Setting this config
/// to a non-zero value will activate periodic cache persistence.
static constexpr std::string_view kAsyncCachePersistenceInterval{
Expand Down Expand Up @@ -1079,6 +1085,8 @@ class SystemConfig : public ConfigBase {

int32_t asyncCacheNumShards() const;

uint64_t asyncCacheSsdFlushThresholdBytes() const;

std::chrono::duration<double> asyncCachePersistenceInterval() const;

bool asyncCacheSsdDisableFileCow() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ TEST_F(ConfigTest, asyncCacheNumShards) {
ASSERT_EQ(config.asyncCacheNumShards(), 8);
}

TEST_F(ConfigTest, asyncCacheSsdFlushThresholdBytes) {
SystemConfig config;
init(config, {});
// Test default value is 0
ASSERT_EQ(config.asyncCacheSsdFlushThresholdBytes(), 0);

// Test custom value
init(
config,
{{std::string(SystemConfig::kAsyncCacheSsdFlushThresholdBytes),
"134217728"}});
ASSERT_EQ(config.asyncCacheSsdFlushThresholdBytes(), 134217728);
}

TEST_F(ConfigTest, remoteFunctionServer) {
SystemConfig config;
init(config, {});
Expand Down
Loading