diff options
author | andrew-rykov <arykov@ydb.tech> | 2023-11-16 12:55:46 +0300 |
---|---|---|
committer | andrew-rykov <arykov@ydb.tech> | 2023-11-16 13:19:24 +0300 |
commit | 33ef64e7d000aaa1ed57e87eae157142edcd1418 (patch) | |
tree | 7499fc5fb9bd02c5dc9b626dc10acb77eb7c4ded | |
parent | 1230368525c69fd8f92bb3bbff1cbc049581e703 (diff) | |
download | ydb-33ef64e7d000aaa1ed57e87eae157142edcd1418.tar.gz |
KIKIMR-19603 added shared cache info and sessions number in nodes handler
added SharedCache to whiteboard
KIKIMR-19603 memory info nodes handler
-rw-r--r-- | ydb/core/kqp/proxy_service/kqp_proxy_service.cpp | 6 | ||||
-rw-r--r-- | ydb/core/node_whiteboard/node_whiteboard.h | 14 | ||||
-rw-r--r-- | ydb/core/protos/node_whiteboard.proto | 7 | ||||
-rw-r--r-- | ydb/core/tablet_flat/shared_sausagecache.cpp | 45 |
4 files changed, 60 insertions, 12 deletions
diff --git a/ydb/core/kqp/proxy_service/kqp_proxy_service.cpp b/ydb/core/kqp/proxy_service/kqp_proxy_service.cpp index 746eaf90a4..54d75f7ba6 100644 --- a/ydb/core/kqp/proxy_service/kqp_proxy_service.cpp +++ b/ydb/core/kqp/proxy_service/kqp_proxy_service.cpp @@ -290,6 +290,7 @@ public: } else { static const TDuration defaultIdleCheckInterval = TDuration::Seconds(2); ScheduleIdleSessionCheck(defaultIdleCheckInterval); + SendWhiteboardStats(); } } @@ -1226,6 +1227,11 @@ public: } } + void SendWhiteboardStats() { + TActorId whiteboardId = NNodeWhiteboard::MakeNodeWhiteboardServiceId(SelfId().NodeId()); + Send(whiteboardId, NNodeWhiteboard::TEvWhiteboard::CreateTotalSessionsUpdateRequest(LocalSessions->size())); + } + STATEFN(MainState) { switch (ev->GetTypeRewrite()) { hFunc(TEvInterconnect::TEvNodeInfo, Handle); diff --git a/ydb/core/node_whiteboard/node_whiteboard.h b/ydb/core/node_whiteboard/node_whiteboard.h index 81d1f67430..cfe29331b5 100644 --- a/ydb/core/node_whiteboard/node_whiteboard.h +++ b/ydb/core/node_whiteboard/node_whiteboard.h @@ -380,6 +380,20 @@ struct TEvWhiteboard{ } }; + static TEvSystemStateUpdate *CreateSharedCacheStatsUpdateRequest(ui64 memUsedBytes, ui64 memLimitBytes) { + TEvSystemStateUpdate *request = new TEvSystemStateUpdate(); + auto *pb = request->Record.MutableSharedCacheStats(); + pb->SetUsedBytes(memUsedBytes); + pb->SetLimitBytes(memLimitBytes); + return request; + } + + static TEvSystemStateUpdate *CreateTotalSessionsUpdateRequest(ui32 totalSessions) { + TEvSystemStateUpdate *request = new TEvSystemStateUpdate(); + request->Record.SetTotalSessions(totalSessions); + return request; + } + struct TEvSystemStateAddEndpoint : TEventLocal<TEvSystemStateAddEndpoint, EvSystemStateAddEndpoint> { TString Name; TString Address; diff --git a/ydb/core/protos/node_whiteboard.proto b/ydb/core/protos/node_whiteboard.proto index 4d496a014f..6ea2acea18 100644 --- a/ydb/core/protos/node_whiteboard.proto +++ b/ydb/core/protos/node_whiteboard.proto @@ -283,6 +283,11 @@ message TSystemStateInfo { optional uint32 Body = 4; } + message TNodeSharedCache { + optional uint64 UsedBytes = 1; + optional uint64 LimitBytes = 2; + } + optional uint64 StartTime = 1; optional uint64 ChangeTime = 2; optional TLegacyNodeLocation SystemLocation = 3; @@ -314,6 +319,8 @@ message TSystemStateInfo { optional int64 MaxClockSkewWithPeerUs = 32; // a positive value means the peer is ahead in time; a negative value means it's behind optional uint32 MaxClockSkewPeerId = 33; optional uint64 DisconnectTime = 34; + optional TNodeSharedCache SharedCacheStats = 35; + optional uint32 TotalSessions = 36; } message TEvSystemStateRequest { diff --git a/ydb/core/tablet_flat/shared_sausagecache.cpp b/ydb/core/tablet_flat/shared_sausagecache.cpp index 40f775ae24..8c78df5349 100644 --- a/ydb/core/tablet_flat/shared_sausagecache.cpp +++ b/ydb/core/tablet_flat/shared_sausagecache.cpp @@ -7,6 +7,7 @@ #include <ydb/core/util/page_map.h> #include <ydb/core/base/blobstorage.h> #include <ydb/core/control/immediate_control_board_impl.h> +#include <ydb/core/node_whiteboard/node_whiteboard.h> #include <library/cpp/actors/core/hfunc.h> #include <library/cpp/containers/stack_vector/stack_vec.h> #include <util/generic/set.h> @@ -73,7 +74,7 @@ public: class TSharedPageCacheMemTableTracker : public std::enable_shared_from_this<TSharedPageCacheMemTableTracker> { friend TSharedPageCacheMemTableRegistration; - + public: TSharedPageCacheMemTableTracker(TIntrusivePtr<TSharedPageCacheCounters> counters) : Counters(counters) @@ -93,7 +94,7 @@ public: ret = MakeIntrusive<TSharedPageCacheMemTableRegistration>(owner, table, weak_from_this()); NonCompacting.insert(ret); } - return ret; + return ret; } void Unregister(TActorId owner, ui32 table) { @@ -203,6 +204,9 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> { PageStateEvicted, }; + static const ui64 DO_GC_TAG = 1; + static const ui64 UPDATE_WHITEBOARD_TAG = 2; + struct TCollection; struct TPage @@ -212,7 +216,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> { ui32 State : 4; ui32 CacheGeneration : 3; ui32 InMemory : 1; - + const ui32 PageId; const size_t Size; @@ -338,7 +342,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> { // 0 means unlimited ui64 MemLimitBytes = 0; ui64 ConfigLimitBytes; - + void ActualizeCacheSizeLimit() { if ((ui64)SizeOverride != Config->CacheConfig->Limit) { Config->CacheConfig->SetLimit(SizeOverride); @@ -971,10 +975,26 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> { } } - void GCWakeup() { - GCScheduled = false; + void Wakeup(TKikimrEvents::TEvWakeup::TPtr& ev) { + switch (ev->Get()->Tag) { + case DO_GC_TAG: { + GCScheduled = false; + ProcessGCList(); + break; + } + case UPDATE_WHITEBOARD_TAG: { + SendWhiteboardStats(); + Schedule(TDuration::Seconds(1), new TKikimrEvents::TEvWakeup(UPDATE_WHITEBOARD_TAG)); + break; + } + default: + Y_ABORT("Unknown wakeup tag: %lu", ev->Get()->Tag); + } + } - ProcessGCList(); + void SendWhiteboardStats() { + TActorId whiteboardId = NNodeWhiteboard::MakeNodeWhiteboardServiceId(SelfId().NodeId()); + Send(whiteboardId, NNodeWhiteboard::TEvWhiteboard::CreateSharedCacheStatsUpdateRequest(GetStatAllBytes(), MemLimitBytes)); } void ProcessGCList() { @@ -1015,7 +1035,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> { void TryScheduleGC() { if (!GCScheduled) { - TActivationContext::AsActorContext().Schedule(TDuration::Seconds(15), new TEvents::TEvWakeup()); + TActivationContext::AsActorContext().Schedule(TDuration::Seconds(15), new TKikimrEvents::TEvWakeup(DO_GC_TAG)); GCScheduled = true; } } @@ -1191,13 +1211,13 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> { void Evict(TIntrusiveList<TPage>&& pages) { while (!pages.Empty()) { TPage* page = pages.PopFront(); - + Y_VERIFY_S(page->CacheGeneration == TCacheCacheConfig::CacheGenEvicted, "unexpected " << page->CacheGeneration << " page cache generation"); page->CacheGeneration = TCacheCacheConfig::CacheGenNone; Y_VERIFY_S(page->State == PageStateLoaded, "unexpected " << page->State << " page state"); page->State = PageStateEvicted; - + RemoveActivePage(page); AddPassivePage(page); if (page->UnUse()) { @@ -1212,7 +1232,7 @@ class TSharedPageCache : public TActorBootstrapped<TSharedPageCache> { Y_VERIFY_S(page->State == PageStateLoaded, "unexpected " << page->State << " page state"); page->State = PageStateEvicted; - + RemoveActivePage(page); AddPassivePage(page); if (page->UnUse()) { @@ -1321,6 +1341,7 @@ public: }); Become(&TThis::StateFunc); + Schedule(TDuration::Seconds(1), new TKikimrEvents::TEvWakeup(UPDATE_WHITEBOARD_TAG)); } STFUNC(StateFunc) { @@ -1337,7 +1358,7 @@ public: hFunc(NBlockIO::TEvData, Handle); hFunc(TEvSharedPageCache::TEvConfigure, Handle); - cFunc(TEvents::TSystem::Wakeup, GCWakeup); + hFunc(TKikimrEvents::TEvWakeup, Wakeup); cFunc(TEvents::TSystem::PoisonPill, TakePoison); } } |