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 @@ -1073,7 +1073,8 @@ void PrestoServer::initializeVeloxMemory() {
velox::cache::AsyncDataCache::Options cacheOptions{
systemConfig->asyncCacheMaxSsdWriteRatio(),
systemConfig->asyncCacheSsdSavableRatio(),
systemConfig->asyncCacheMinSsdSavableBytes()};
systemConfig->asyncCacheMinSsdSavableBytes(),
systemConfig->asyncCacheNumShards()};
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 @@ -209,6 +209,7 @@ SystemConfig::SystemConfig() {
NUM_PROP(kAsyncCacheMaxSsdWriteRatio, 0.7),
NUM_PROP(kAsyncCacheSsdSavableRatio, 0.125),
NUM_PROP(kAsyncCacheMinSsdSavableBytes, 1 << 24 /*16MB*/),
NUM_PROP(kAsyncCacheNumShards, 4),
STR_PROP(kAsyncCachePersistenceInterval, "0s"),
BOOL_PROP(kAsyncCacheSsdDisableFileCow, false),
BOOL_PROP(kSsdCacheChecksumEnabled, false),
Expand Down Expand Up @@ -695,6 +696,10 @@ int32_t SystemConfig::asyncCacheMinSsdSavableBytes() const {
return optionalProperty<int32_t>(kAsyncCacheMinSsdSavableBytes).value();
}

int32_t SystemConfig::asyncCacheNumShards() const {
return optionalProperty<int32_t>(kAsyncCacheNumShards).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 @@ -429,6 +429,12 @@ class SystemConfig : public ConfigBase {
static constexpr std::string_view kAsyncCacheMinSsdSavableBytes{
"async-cache-min-ssd-savable-bytes"};

/// The number of shards for the async data cache. The cache is divided into
/// shards to decrease contention on the mutex for the key to entry mapping
/// and other housekeeping. Must be a power of 2.
static constexpr std::string_view kAsyncCacheNumShards{
"async-cache-num-shards"};

/// 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 @@ -1066,6 +1072,8 @@ class SystemConfig : public ConfigBase {

int32_t asyncCacheMinSsdSavableBytes() const;

int32_t asyncCacheNumShards() const;

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

bool asyncCacheSsdDisableFileCow() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ TEST_F(ConfigTest, optionalSystemConfigsWithDefault) {
ASSERT_EQ(config.maxDriversPerTask(), 1024);
}

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

// Test custom value
init(config, {{std::string(SystemConfig::kAsyncCacheNumShards), "8"}});
ASSERT_EQ(config.asyncCacheNumShards(), 8);
}

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