From d26b6de65ba58129a5166d2596ce618eacecd059 Mon Sep 17 00:00:00 2001 From: Jialiang Tan Date: Sun, 6 Aug 2023 14:29:52 -0700 Subject: [PATCH] Rename AsyncDataCache::prepareShutdown to shutdown (#5970) Summary: Renaming it to align with convention. Pull Request resolved: https://github.com/facebookincubator/velox/pull/5970 Reviewed By: xiaoxmeng Differential Revision: D48000556 Pulled By: tanjialiang fbshipit-source-id: a982adf28097ff540662e9d188b58b482cbc9ecd --- velox/benchmarks/tpch/TpchBenchmark.cpp | 2 +- velox/common/caching/AsyncDataCache.cpp | 11 +++++++++-- velox/common/caching/AsyncDataCache.h | 7 ++++++- velox/common/caching/tests/AsyncDataCacheTest.cpp | 4 ++-- velox/common/caching/tests/SsdFileTest.cpp | 2 +- velox/common/memory/tests/MemoryPoolTest.cpp | 2 +- velox/dwio/dwrf/test/CacheInputTest.cpp | 2 +- velox/exec/tests/utils/OperatorTestBase.cpp | 2 +- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/velox/benchmarks/tpch/TpchBenchmark.cpp b/velox/benchmarks/tpch/TpchBenchmark.cpp index 8890a50a8e1b..f02ebf64b7bf 100644 --- a/velox/benchmarks/tpch/TpchBenchmark.cpp +++ b/velox/benchmarks/tpch/TpchBenchmark.cpp @@ -263,7 +263,7 @@ class TpchBenchmark { } void shutdown() { - cache_->prepareShutdown(); + cache_->shutdown(); } std::pair, std::vector> run( diff --git a/velox/common/caching/AsyncDataCache.cpp b/velox/common/caching/AsyncDataCache.cpp index 364c5f66f104..7d907b583da5 100644 --- a/velox/common/caching/AsyncDataCache.cpp +++ b/velox/common/caching/AsyncDataCache.cpp @@ -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(); } diff --git a/velox/common/caching/AsyncDataCache.h b/velox/common/caching/AsyncDataCache.h index 941a2f61157d..aab4eea3565c 100644 --- a/velox/common/caching/AsyncDataCache.h +++ b/velox/common/caching/AsyncDataCache.h @@ -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 @@ -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 diff --git a/velox/common/caching/tests/AsyncDataCacheTest.cpp b/velox/common/caching/tests/AsyncDataCacheTest.cpp index 66bb6dd65cbd..37dd11a25aff 100644 --- a/velox/common/caching/tests/AsyncDataCacheTest.cpp +++ b/velox/common/caching/tests/AsyncDataCacheTest.cpp @@ -81,7 +81,7 @@ class AsyncDataCacheTest : public testing::Test { if (ssdCache) { ssdCache->deleteFiles(); } - cache_->prepareShutdown(); + cache_->shutdown(); } } @@ -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(); diff --git a/velox/common/caching/tests/SsdFileTest.cpp b/velox/common/caching/tests/SsdFileTest.cpp index c4d7c93df2bd..9e6dd666d48b 100644 --- a/velox/common/caching/tests/SsdFileTest.cpp +++ b/velox/common/caching/tests/SsdFileTest.cpp @@ -46,7 +46,7 @@ class SsdFileTest : public testing::Test { ssdFile_->deleteFile(); } if (cache_) { - cache_->prepareShutdown(); + cache_->shutdown(); } } diff --git a/velox/common/memory/tests/MemoryPoolTest.cpp b/velox/common/memory/tests/MemoryPoolTest.cpp index f0aeae61c0b4..6d9c151e6599 100644 --- a/velox/common/memory/tests/MemoryPoolTest.cpp +++ b/velox/common/memory/tests/MemoryPoolTest.cpp @@ -110,7 +110,7 @@ class MemoryPoolTest : public testing::TestWithParam { void TearDown() override { if (useCache_) { - cache_->prepareShutdown(); + cache_->shutdown(); } allocator_->testingClearFailureInjection(); MmapAllocator::setDefaultInstance(nullptr); diff --git a/velox/dwio/dwrf/test/CacheInputTest.cpp b/velox/dwio/dwrf/test/CacheInputTest.cpp index 3bb9c588d2c2..5174250f8b9b 100644 --- a/velox/dwio/dwrf/test/CacheInputTest.cpp +++ b/velox/dwio/dwrf/test/CacheInputTest.cpp @@ -115,7 +115,7 @@ class CacheTest : public testing::Test { ssdCache->deleteFiles(); } if (cache_) { - cache_->prepareShutdown(); + cache_->shutdown(); } } diff --git a/velox/exec/tests/utils/OperatorTestBase.cpp b/velox/exec/tests/utils/OperatorTestBase.cpp index 714606759937..3fd00d10d4a1 100644 --- a/velox/exec/tests/utils/OperatorTestBase.cpp +++ b/velox/exec/tests/utils/OperatorTestBase.cpp @@ -72,7 +72,7 @@ void OperatorTestBase::SetUp() { void OperatorTestBase::TearDown() { if (asyncDataCache_ != nullptr) { - asyncDataCache_->prepareShutdown(); + asyncDataCache_->shutdown(); } }