Skip to content

Commit

Permalink
Clear attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsaka committed Mar 8, 2024
1 parent 4fb3535 commit 1df9082
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions velox/common/caching/AsyncDataCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ bool AsyncDataCache::makeSpace(
// serialize with a mutex because memory arbitration must not be
// called from inside a global mutex.

clearMemoryCache();

constexpr int32_t kMaxAttempts = kNumShards * 4;
// Evict at least 1MB even for small allocations to avoid constantly hitting
// the mutex protected evict loop.
Expand Down Expand Up @@ -883,6 +885,13 @@ void AsyncDataCache::clear() {
}
}

void AsyncDataCache::clearMemoryCache() {
for (auto& shard : shards_) {
memory::Allocation unused;
shard->evict(std::numeric_limits<uint64_t>::max(), false, 0, unused);
}
}

std::string AsyncDataCache::toString(bool details) const {
auto stats = refreshStats();
std::stringstream out;
Expand Down
3 changes: 3 additions & 0 deletions velox/common/caching/AsyncDataCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,9 @@ class AsyncDataCache : public memory::Cache {
// Drops all unpinned entries. Pins stay valid.
void clear();

// Drops all unpinned entries. Pins stay valid.
void clearMemoryCache();

// Saves all entries with 'ssdSaveable_' to 'ssdCache_'.
void saveToSsd();

Expand Down

0 comments on commit 1df9082

Please sign in to comment.