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

Method UpdateCharge

be/src/util/cache/rl-cache.cc:344–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342
343template<Cache::EvictionPolicy policy>
344void RLCacheShard<policy>::UpdateCharge(HandleBase* handle, size_t charge) {
345 DCHECK(initialized_);
346
347 // Check for eviction based on new usage
348 RLThreadState tstate;
349 {
350 // Hold the lock to avoid concurrent evictions
351 std::lock_guard<decltype(mutex_)> l(mutex_);
352 RLHandle* e = static_cast<RLHandle*>(handle);
353 // If the handle is not part of the cache (i.e. it was evicted),
354 // then we shouldn't update the charge. The caller has a handle to
355 // the entry, so it was previously in the cache.
356 if (e->next == nullptr) return;
357 int64_t delta = charge - handle->charge();
358 handle->set_charge(charge);
359 UpdateMemTracker(delta);
360 usage_ += delta;
361
362 // Evict entries as needed to enforce the capacity constraint
363 EnforceCapacity(&tstate);
364 }
365
366 // we free the entries here outside of mutex for performance reasons
367 CleanupThreadState(&tstate);
368}
369
370template<Cache::EvictionPolicy policy>
371void RLCacheShard<policy>::Release(HandleBase* handle) {

Callers 4

UpdateWriteSizeMethod · 0.45
AbortWriteMethod · 0.45
TEST_FFunction · 0.45
TEST_PFunction · 0.45

Calls 2

chargeMethod · 0.80
set_chargeMethod · 0.80

Tested by 2

TEST_FFunction · 0.36
TEST_PFunction · 0.36