feat(native): Add config for asyc cache numShards#27073
Merged
xiaoxmeng merged 1 commit intoprestodb:masterfrom Feb 4, 2026
Merged
feat(native): Add config for asyc cache numShards#27073xiaoxmeng merged 1 commit intoprestodb:masterfrom
xiaoxmeng merged 1 commit intoprestodb:masterfrom
Conversation
Contributor
Reviewer's GuideIntroduce a new configuration property async-cache-num-shards to control the number of shards used by the async data cache, plumb it through SystemConfig with a default of 4, and pass it into AsyncDataCache options along with unit tests for the default and override behavior. Sequence diagram for passing async cache numShards into AsyncDataCachesequenceDiagram
actor Admin
participant SystemConfig
participant PrestoServer
participant AsyncDataCache
Admin->>SystemConfig: Set async-cache-num-shards (optional)
Admin->>PrestoServer: Start server
PrestoServer->>SystemConfig: asyncCacheMaxSsdWriteRatio()
SystemConfig-->>PrestoServer: maxSsdWriteRatio
PrestoServer->>SystemConfig: asyncCacheSsdSavableRatio()
SystemConfig-->>PrestoServer: ssdSavableRatio
PrestoServer->>SystemConfig: asyncCacheMinSsdSavableBytes()
SystemConfig-->>PrestoServer: minSsdSavableBytes
PrestoServer->>SystemConfig: asyncCacheNumShards()
SystemConfig-->>PrestoServer: numShards (default 4 or overridden)
PrestoServer->>AsyncDataCache: create(allocator, ssd, Options{maxSsdWriteRatio, ssdSavableRatio, minSsdSavableBytes, numShards})
AsyncDataCache-->>PrestoServer: cache_instance_with_shards
Class diagram for new async cache numShards configurationclassDiagram
class ConfigBase
class SystemConfig {
<<Config>>
+static constexpr string_view kAsyncCacheNumShards
+int32_t asyncCacheMinSsdSavableBytes() const
+int32_t asyncCacheNumShards() const
+std_chrono_duration_double asyncCachePersistenceInterval() const
+bool asyncCacheSsdDisableFileCow() const
}
class PrestoServer {
+void initializeVeloxMemory()
-shared_ptr_AsyncDataCache cache_
}
class AsyncDataCacheOptions {
+double maxSsdWriteRatio
+double ssdSavableRatio
+int32_t minSsdSavableBytes
+int32_t numShards
}
class AsyncDataCache {
+static shared_ptr_AsyncDataCache create(Allocator allocator, unique_ptr_SsdCache ssd, AsyncDataCacheOptions options)
}
ConfigBase <|-- SystemConfig
PrestoServer ..> SystemConfig : reads_config
PrestoServer ..> AsyncDataCacheOptions : constructs
PrestoServer ..> AsyncDataCache : create_with_numShards
AsyncDataCacheOptions ..> AsyncDataCache : used_to_configure
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Given the comment that
async-cache-num-shards"must be a power of 2", consider adding explicit validation (and a clear error message) when reading this config to guard against non-power-of-two or non-positive values rather than silently accepting bad input. - It may be worth clarifying in the new test (or via an additional one) how the system behaves when
async-cache-num-shardsis set to an invalid value (e.g., 0 or negative), to ensure the contract around this config is well-defined and enforced.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Given the comment that `async-cache-num-shards` "must be a power of 2", consider adding explicit validation (and a clear error message) when reading this config to guard against non-power-of-two or non-positive values rather than silently accepting bad input.
- It may be worth clarifying in the new test (or via an additional one) how the system behaves when `async-cache-num-shards` is set to an invalid value (e.g., 0 or negative), to ensure the contract around this config is well-defined and enforced.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
steveburnett
reviewed
Feb 3, 2026
Contributor
steveburnett
left a comment
There was a problem hiding this comment.
Please include documentation for the new property, as described in Designing Your Code in CONTRIBUTING.md:
"All new language features, new functions, session and config properties, and major features have documentation added"
This was referenced Mar 31, 2026
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Add configurable shard count for the async data cache and wire it through server initialization.
New Features:
Tests: