MCPcopy Create free account
hub / github.com/apache/impala / UpdateCharge

Method UpdateCharge

be/src/util/cache/lirs-cache.cc:956–995  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

954}
955
956void LIRSCacheShard::UpdateCharge(HandleBase* handle, size_t charge) {
957 DCHECK(initialized_);
958 LIRSThreadState tstate;
959 {
960 // Hold the lock to avoid concurrent evictions
961 std::lock_guard<MutexType> l(mutex_);
962 LIRSHandle* e = static_cast<LIRSHandle*>(handle);
963 // Entries that are UNINITIALIZED or TOMBSTONE do not count towards
964 // the usage and will be destroyed without interacting with the usage.
965 // Skip modifying the charge.
966 //
967 // In the case of UNINITIALIZED, we know that the caller has a handle
968 // for the entry, so it needs to have been in the cache previously
969 // (i.e. it was found via Lookup() or added via Insert()). So, in this
970 // context, UNINITIALIZED can only mean that it has been evicted.
971 if (e->state() == UNINITIALIZED || e->state() == TOMBSTONE) {
972 return;
973 }
974 DCHECK(e->state() == PROTECTED || e->state() == UNPROTECTED);
975 int64_t delta = charge - handle->charge();
976 handle->set_charge(charge);
977 UpdateMemTracker(delta);
978 // Update usage in existing state, then evict as needed.
979 switch (e->state()) {
980 case PROTECTED:
981 protected_usage_ += delta;
982 EnforceProtectedCapacity(&tstate);
983 break;
984 case UNPROTECTED:
985 unprotected_usage_ += delta;
986 EnforceUnprotectedCapacity(&tstate);
987 break;
988 default:
989 // This can't happen.
990 CHECK(false) << "Unexpected state for UpdateCharge: " << e->state();
991 break;
992 }
993 }
994 CleanupThreadState(&tstate);
995}
996
997void LIRSCacheShard::Release(HandleBase* handle) {
998 DCHECK(initialized_);

Callers

nothing calls this directly

Calls 3

chargeMethod · 0.80
set_chargeMethod · 0.80
stateMethod · 0.45

Tested by

no test coverage detected