MCPcopy Create free account
hub / github.com/bytedance/bolt / removeFileEntries

Method removeFileEntries

bolt/common/caching/AsyncDataCache.cpp:589–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

587}
588
589bool 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
637AsyncDataCache::AsyncDataCache(
638 memory::MemoryAllocator* allocator,

Callers

nothing calls this directly

Calls 13

isExclusiveMethod · 0.80
isSharedMethod · 0.80
incrementCachedPagesMethod · 0.80
emptyMethod · 0.45
hasValueMethod · 0.45
countMethod · 0.45
idMethod · 0.45
insertMethod · 0.45
numPagesMethod · 0.45
dataMethod · 0.45
push_backMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected