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

Method SuggestPurgeCache

library/cpp/neh/http2.cpp:1016–1039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1014 }
1015
1016 void SuggestPurgeCache() {
1017 if (InPurging_.TryAcquire()) {
1018 //evaluate the usefulness of purging the cache
1019 //если в кеше мало соединений (< MaxConnId_/16 или 64), не чистим кеш
1020 if (Cache_.Size() > (Min((size_t)AtomicGet(MaxConnId_), (size_t)1024U) >> 4)) {
1021 //по мере приближения к hardlimit нужда в чистке cache приближается к 100%
1022 size_t closenessToHardLimit256 = ((Active() + 1) << 8) / (Limits.Delta() + 1);
1023 //чем больше соединений в кеше, а не в работе, тем менее нужен кеш (можно его почистить)
1024 size_t cacheUselessness256 = ((Cache_.Size() + 1) << 8) / (Active() + 1);
1025
1026 //итого, - пороги срабатывания:
1027 //при достижении soft-limit, если соединения в кеше, а не в работе
1028 //на полпути от soft-limit к hard-limit, если в кеше больше половины соединений
1029 //при приближении к hardlimit пытаться почистить кеш почти постоянно
1030 if ((closenessToHardLimit256 + cacheUselessness256) >= 256U) {
1031 TGuard<TMutex> g(PurgeMutex_);
1032
1033 CondPurge_.Signal();
1034 return; //memo: thread MUST unlock InPurging_ (see DoExecute())
1035 }
1036 }
1037 InPurging_.Release();
1038 }
1039 }
1040
1041 void DoExecute() override {
1042 TThread::SetCurrentThreadName("NehHttpConnMngr");

Callers

nothing calls this directly

Calls 7

DeltaMethod · 0.80
MinFunction · 0.50
AtomicGetFunction · 0.50
TryAcquireMethod · 0.45
SizeMethod · 0.45
SignalMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected