MCPcopy Create free account
hub / github.com/catboost/catboost / SuggestPurgeCache

Method SuggestPurgeCache

library/cpp/neh/https.cpp:548–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546
547 private:
548 void SuggestPurgeCache() {
549 if (InPurging_.TryAcquire()) {
550 //evaluate the usefulness of purging the cache
551 //если в кеше мало соединений (< MaxConnId_/16 или 64), не чистим кеш
552 if ((size_t)CachedConnections.Val() > (Min((size_t)MaxConnId_.load(std::memory_order_acquire), (size_t)1024U) >> 4)) {
553 //по мере приближения к hardlimit нужда в чистке cache приближается к 100%
554 size_t closenessToHardLimit256 = ((ActiveConnections.Val() + 1) << 8) / (Limits.Delta() + 1);
555 //чем больше соединений в кеше, а не в работе, тем менее нужен кеш (можно его почистить)
556 size_t cacheUselessness256 = ((CachedConnections.Val() + 1) << 8) / (ActiveConnections.Val() + 1);
557
558 //итого, - пороги срабатывания:
559 //при достижении soft-limit, если соединения в кеше, а не в работе
560 //на полпути от soft-limit к hard-limit, если в кеше больше половины соединений
561 //при приближении к hardlimit пытаться почистить кеш почти постоянно
562 if ((closenessToHardLimit256 + cacheUselessness256) >= 256U) {
563 TGuard<TMutex> g(PurgeMutex_);
564
565 CondPurge_.Signal();
566 return; //memo: thread MUST unlock InPurging_ (see DoExecute())
567 }
568 }
569 InPurging_.Release();
570 }
571 }
572
573 void DoExecute() override {
574 while (true) {

Callers

nothing calls this directly

Calls 7

DeltaMethod · 0.80
MinFunction · 0.50
TryAcquireMethod · 0.45
ValMethod · 0.45
loadMethod · 0.45
SignalMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected