Skip to content

Commit

Permalink
Rename AsyncDataCache::prepareShutdown to shutdown (facebookincubator…
Browse files Browse the repository at this point in the history
…#5970)

Summary:
Renaming it to align with convention.

Pull Request resolved: facebookincubator#5970

Reviewed By: xiaoxmeng

Differential Revision: D48000556

Pulled By: tanjialiang

fbshipit-source-id: a982adf28097ff540662e9d188b58b482cbc9ecd
  • Loading branch information
tanjialiang authored and facebook-github-bot committed Aug 6, 2023
1 parent b72122b commit d26b6de
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion velox/benchmarks/tpch/TpchBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class TpchBenchmark {
}

void shutdown() {
cache_->prepareShutdown();
cache_->shutdown();
}

std::pair<std::unique_ptr<TaskCursor>, std::vector<RowVectorPtr>> run(
Expand Down
11 changes: 9 additions & 2 deletions velox/common/caching/AsyncDataCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,20 @@ AsyncDataCache** AsyncDataCache::getInstancePtr() {
return &cache_;
}

#ifdef VELOX_ENABLE_BACKWARD_COMPATIBILITY
void AsyncDataCache::prepareShutdown() {
for (auto& shard : shards_) {
shard->prepareShutdown();
shard->shutdown();
}
}
#endif
void AsyncDataCache::shutdown() {
for (auto& shard : shards_) {
shard->shutdown();
}
}

void CacheShard::prepareShutdown() {
void CacheShard::shutdown() {
entries_.clear();
freeEntries_.clear();
}
Expand Down
7 changes: 6 additions & 1 deletion velox/common/caching/AsyncDataCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ class CacheShard {

/// Release any resources that consume memory from this 'CacheShard' for a
/// graceful shutdown. The shard will no longer be valid after this call.
void prepareShutdown();
void shutdown();

// removes 'bytesToFree' worth of entries or as many entries as are
// not pinned. This favors first removing older and less frequently
Expand Down Expand Up @@ -634,9 +634,14 @@ class AsyncDataCache : public memory::Cache {

static void setInstance(AsyncDataCache* asyncDataCache);

#ifdef VELOX_ENABLE_BACKWARD_COMPATIBILITY
/// Release any resources that consume memory from 'allocator_' for a graceful
/// shutdown. The cache will no longer be valid after this call.
void prepareShutdown();
#endif
/// Release any resources that consume memory from 'allocator_' for a graceful
/// shutdown. The cache will no longer be valid after this call.
void shutdown();

/// Calls 'allocate' until this returns true. Returns true if
/// allocate returns true. and Tries to evict at least 'numPages' of
Expand Down
4 changes: 2 additions & 2 deletions velox/common/caching/tests/AsyncDataCacheTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AsyncDataCacheTest : public testing::Test {
if (ssdCache) {
ssdCache->deleteFiles();
}
cache_->prepareShutdown();
cache_->shutdown();
}
}

Expand All @@ -106,7 +106,7 @@ class AsyncDataCacheTest : public testing::Test {
memory::MmapAllocator::Options options;
options.capacity = maxBytes;
if (cache_) {
cache_->prepareShutdown();
cache_->shutdown();
}
cache_.reset();
allocator_.reset();
Expand Down
2 changes: 1 addition & 1 deletion velox/common/caching/tests/SsdFileTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SsdFileTest : public testing::Test {
ssdFile_->deleteFile();
}
if (cache_) {
cache_->prepareShutdown();
cache_->shutdown();
}
}

Expand Down
2 changes: 1 addition & 1 deletion velox/common/memory/tests/MemoryPoolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class MemoryPoolTest : public testing::TestWithParam<TestParam> {

void TearDown() override {
if (useCache_) {
cache_->prepareShutdown();
cache_->shutdown();
}
allocator_->testingClearFailureInjection();
MmapAllocator::setDefaultInstance(nullptr);
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/test/CacheInputTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CacheTest : public testing::Test {
ssdCache->deleteFiles();
}
if (cache_) {
cache_->prepareShutdown();
cache_->shutdown();
}
}

Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/utils/OperatorTestBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void OperatorTestBase::SetUp() {

void OperatorTestBase::TearDown() {
if (asyncDataCache_ != nullptr) {
asyncDataCache_->prepareShutdown();
asyncDataCache_->shutdown();
}
}

Expand Down

0 comments on commit d26b6de

Please sign in to comment.