[native] Add support for cache periodic full persistence#23192
[native] Add support for cache periodic full persistence#23192zacw7 merged 1 commit intoprestodb:masterfrom
Conversation
2c32db5 to
d7b351f
Compare
abc9e4c to
d6c42f1
Compare
aditi-pandit
left a comment
There was a problem hiding this comment.
Thanks @zacw7.
Please can you add a release note for this functionality. Would greatly help users.
d6c42f1 to
c3a7675
Compare
release note added. thanks! |
|
Nit, please add the PR number to the release note entry following the Release Notes Guidelines: |
| auto* cache = velox::cache::AsyncDataCache::getInstance(); | ||
| if (cache == nullptr) { | ||
| return; | ||
| } | ||
|
|
||
| auto* ssdCache = cache->ssdCache(); | ||
| if (ssdCache == nullptr) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
is it possible to get ssd cache outside of the periodic func? Also if isCachePeriodicFullPersistenceEnabled() is true shouldn't cache and ssdcache both be non-null? Can we change these conditions to VELOX_CHECKs?
There was a problem hiding this comment.
If cache and ssdcache both are non-null, shall we just ignore it instead of failing the server hard? Similarly, we still allow the server operation api to be called even when there is no cache:
There was a problem hiding this comment.
What I meant is something like this
if (isCachePeriodicFullPersistenceEnabled()) {
VELOX_CHECK_NOT_NULL(cache);
VELOX_CHECK_NOT_NULL(ssdCache);
}
Or are there any scenarios that they can actually be NULL when the if condition is true?
c3a7675 to
2342987
Compare
tanjialiang
left a comment
There was a problem hiding this comment.
Thanks @zacw7 for the revision. Some minors
| } | ||
|
|
||
| void PrestoServer::addServerPeriodicTasks() { | ||
| const auto* systemConfig = SystemConfig::instance(); |
There was a problem hiding this comment.
I think you need to capture this pointer by copy in the below lambda. Or you can simply put the SystemConfig::instance() call inside lambda. Yeah let's just move it inside lambda. There is not a strong need of having it outside.
| auto* cache = velox::cache::AsyncDataCache::getInstance(); | ||
| if (cache == nullptr) { | ||
| return; | ||
| } | ||
|
|
||
| auto* ssdCache = cache->ssdCache(); | ||
| if (ssdCache == nullptr) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
What I meant is something like this
if (isCachePeriodicFullPersistenceEnabled()) {
VELOX_CHECK_NOT_NULL(cache);
VELOX_CHECK_NOT_NULL(ssdCache);
}
Or are there any scenarios that they can actually be NULL when the if condition is true?
2342987 to
23549b8
Compare
23549b8 to
f1b2046
Compare
Currently, maxWriteRatio(AsyncDataCache::Options), the maximum ratio of the number of in-memory cache entries being written to the SSD cache over the total number of cache entries, is set to the default value of 0.7, meaning that we only persist 70% of cache entries to the SSD and upon server restart 30% of cache will be lost. This change adds an optional periodic daemon to flush cache data to ssd. This can help to make sure all the in-memory data is flushed to ssd.
f1b2046 to
610253b
Compare
| return; | ||
| } | ||
| LOG(INFO) << "Persisting full cache to SSD..."; | ||
| cache->saveToSsd(true); |
Description
Currently, maxWriteRatio(AsyncDataCache::Options), the maximum ratio of the number of in-memory cache entries being written to the SSD cache over the total number of cache entries, is set to the default value of 0.7, meaning that we only persist 70% of cache entries to the SSD and upon server restart 30% of cache will be lost.
This change adds an optional periodic daemon to flush cache data to ssd. This can help to make sure all the in-memory data is flushed to ssd.