| 587 | } |
| 588 | |
| 589 | bool CacheShard::removeFileEntries( |
| 590 | const folly::F14FastSet<uint64_t>& filesToRemove, |
| 591 | folly::F14FastSet<uint64_t>& filesRetained) { |
| 592 | if (filesToRemove.empty()) { |
| 593 | BOLT_CACHE_LOG(INFO) << "Removed 0 AsyncDataCache entry."; |
| 594 | return true; |
| 595 | } |
| 596 | |
| 597 | int64_t pagesRemoved = 0; |
| 598 | std::vector<memory::Allocation> toFree; |
| 599 | { |
| 600 | std::lock_guard<std::mutex> l(mutex_); |
| 601 | |
| 602 | auto entryIndex = -1; |
| 603 | for (auto& cacheEntry : entries_) { |
| 604 | entryIndex++; |
| 605 | if (!cacheEntry || !cacheEntry->key_.fileNum.hasValue()) { |
| 606 | continue; |
| 607 | } |
| 608 | if (filesToRemove.count(cacheEntry->key_.fileNum.id()) == 0) { |
| 609 | continue; |
| 610 | } |
| 611 | if (cacheEntry->isExclusive() || cacheEntry->isShared()) { |
| 612 | filesRetained.insert(cacheEntry->key_.fileNum.id()); |
| 613 | continue; |
| 614 | } |
| 615 | |
| 616 | numAgedOut_++; |
| 617 | pagesRemoved += (int64_t)cacheEntry->data().numPages(); |
| 618 | |
| 619 | toFree.push_back(std::move(cacheEntry->data())); |
| 620 | removeEntryLocked(cacheEntry.get()); |
| 621 | emptySlots_.push_back(entryIndex); |
| 622 | tryAddFreeEntry(std::move(cacheEntry)); |
| 623 | cacheEntry = nullptr; |
| 624 | } |
| 625 | } |
| 626 | BOLT_CACHE_LOG(INFO) << "Removed " << toFree.size() |
| 627 | << " AsyncDataCache entries."; |
| 628 | |
| 629 | // Free the memory allocation out of the cache shard lock. |
| 630 | ClockTimer t(allocClocks_); |
| 631 | freeAllocations(toFree); |
| 632 | cache_->incrementCachedPages(-pagesRemoved); |
| 633 | |
| 634 | return true; |
| 635 | } |
| 636 | |
| 637 | AsyncDataCache::AsyncDataCache( |
| 638 | memory::MemoryAllocator* allocator, |
nothing calls this directly
no test coverage detected