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

Method removeEntryLocked

bolt/common/caching/AsyncDataCache.cpp:355–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355void CacheShard::removeEntryLocked(AsyncDataCacheEntry* entry) {
356 if (!entry->key_.fileNum.hasValue()) {
357 return;
358 }
359 const auto it = entryMap_.find(
360 RawFileCacheKey{entry->key_.fileNum.id(), entry->key_.offset});
361 BOLT_CHECK(it != entryMap_.end());
362 entryMap_.erase(it);
363 entry->key_.fileNum.clear();
364 entry->setSsdFile(nullptr, 0);
365 if (entry->isPrefetch()) {
366 entry->setPrefetch(false);
367 }
368 // An entry can have data allocated if we remove it after failing
369 // to fill it. Free the data and account for the difference. In
370 // eviction, the data of the evicted entries is moved away, so
371 // that freeing while holding the shard mutex is exceptional.
372 const auto numPages = entry->data().numPages();
373 if (numPages > 0) {
374 cache_->incrementCachedPages(-numPages);
375 cache_->allocator()->freeNonContiguous(entry->data());
376 }
377 entry->tinyData_.clear();
378 entry->tinyData_.shrink_to_fit();
379 entry->size_ = 0;
380}
381
382uint64_t CacheShard::evict(
383 uint64_t bytesToFree,

Callers

nothing calls this directly

Calls 14

setSsdFileMethod · 0.80
isPrefetchMethod · 0.80
setPrefetchMethod · 0.80
incrementCachedPagesMethod · 0.80
hasValueMethod · 0.45
findMethod · 0.45
idMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
clearMethod · 0.45
numPagesMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected