diff options
author | kungurtsev <kungasc@ydb.tech> | 2024-08-30 10:17:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-30 10:17:32 +0200 |
commit | ecf7e68d30dd06f13cacb05b19581cd958501583 (patch) | |
tree | 29cea24893bb64f9d344bef68e96d42bafea3409 | |
parent | 72213a07551489110418291f34854d28d4baaa0a (diff) | |
download | ydb-ecf7e68d30dd06f13cacb05b19581cd958501583.tar.gz |
Return MemoryStats to node whiteboard (#8455)
-rw-r--r-- | ydb/core/memory_controller/memory_controller.cpp | 3 | ||||
-rw-r--r-- | ydb/core/protos/memory_stats.proto | 6 | ||||
-rw-r--r-- | ydb/core/protos/node_whiteboard.proto | 2 | ||||
-rw-r--r-- | ydb/core/tablet/node_whiteboard.cpp | 45 |
4 files changed, 32 insertions, 24 deletions
diff --git a/ydb/core/memory_controller/memory_controller.cpp b/ydb/core/memory_controller/memory_controller.cpp index 5938d58bf79..a0a9794b6b3 100644 --- a/ydb/core/memory_controller/memory_controller.cpp +++ b/ydb/core/memory_controller/memory_controller.cpp @@ -224,8 +224,6 @@ private: memoryStats.SetHardLimit(hardLimitBytes); memoryStats.SetSoftLimit(softLimitBytes); memoryStats.SetTargetUtilization(targetUtilizationBytes); - memoryStats.SetConsumersConsumption(consumersConsumption); - memoryStats.SetOtherConsumption(otherConsumption); if (hasMemTotalHardLimit) memoryStats.SetExternalConsumption(externalConsumption); ui64 consumersLimitBytes = 0; @@ -251,7 +249,6 @@ private: } Counters->GetCounter("Stats/ConsumersLimit")->Set(consumersLimitBytes); - memoryStats.SetConsumersLimit(consumersLimitBytes); ui64 queryExecutionConsumption = TAlignedPagePool::GetGlobalPagePoolSize(); ui64 queryExecutionLimitBytes = ResourceBrokerSelfConfig.QueryExecutionLimitBytes diff --git a/ydb/core/protos/memory_stats.proto b/ydb/core/protos/memory_stats.proto index 871f7bce267..260d531ad8f 100644 --- a/ydb/core/protos/memory_stats.proto +++ b/ydb/core/protos/memory_stats.proto @@ -14,9 +14,9 @@ message TMemoryStats { optional uint64 SoftLimit = 8; optional uint64 TargetUtilization = 9; - optional uint64 ConsumersConsumption = 10; - optional uint64 ConsumersLimit = 11; - optional uint64 OtherConsumption = 12; + reserved 10; + reserved 11; + reserved 12; optional uint64 ExternalConsumption = 13; optional uint64 SharedCacheConsumption = 14; diff --git a/ydb/core/protos/node_whiteboard.proto b/ydb/core/protos/node_whiteboard.proto index 783e937c391..5ca65c21945 100644 --- a/ydb/core/protos/node_whiteboard.proto +++ b/ydb/core/protos/node_whiteboard.proto @@ -2,6 +2,7 @@ import "ydb/library/actors/protos/interconnect.proto"; import "ydb/core/protos/tablet.proto"; import "ydb/core/protos/subdomains.proto"; import "ydb/core/protos/blobstorage_disk.proto"; +import "ydb/core/protos/memory_stats.proto"; import "google/protobuf/descriptor.proto"; import "ydb/core/protos/tracing.proto"; @@ -339,6 +340,7 @@ message TSystemStateInfo { optional TNodeSharedCache SharedCacheStats = 35; // TODO: use memory stats optional uint32 TotalSessions = 36 [(DefaultField) = true]; optional string NodeName = 37 [(DefaultField) = true]; + optional NKikimrMemory.TMemoryStats MemoryStats = 38; } message TEvSystemStateRequest { diff --git a/ydb/core/tablet/node_whiteboard.cpp b/ydb/core/tablet/node_whiteboard.cpp index c85ea2f6ed7..6d0f1d4c315 100644 --- a/ydb/core/tablet/node_whiteboard.cpp +++ b/ydb/core/tablet/node_whiteboard.cpp @@ -77,7 +77,6 @@ protected: i64 MaxClockSkewWithPeerUs; ui32 MaxClockSkewPeerId; NKikimrWhiteboard::TSystemStateInfo SystemStateInfo; - NKikimrMemory::TMemoryStats MemoryStats; THolder<NTracing::ITraceCollection> TabletIntrospectionData; ::NMonitoring::TDynamicCounters::TCounterPtr MaxClockSkewWithPeerUsCounter; @@ -691,31 +690,41 @@ protected: } void Handle(TEvWhiteboard::TEvMemoryStatsUpdate::TPtr &ev, const TActorContext &ctx) { - MemoryStats.Swap(&ev->Get()->Record); + const auto& memoryStats = ev->Get()->Record; // Note: copy stats to sys info fields for backward compatibility - NKikimrWhiteboard::TSystemStateInfo systemStateUpdate; - if (MemoryStats.HasAnonRss()) { - systemStateUpdate.SetMemoryUsed(MemoryStats.GetAnonRss()); + if (memoryStats.HasAnonRss()) { + SystemStateInfo.SetMemoryUsed(memoryStats.GetAnonRss()); + } else { + SystemStateInfo.ClearMemoryUsed(); } - if (MemoryStats.HasHardLimit()) { - systemStateUpdate.SetMemoryLimit(MemoryStats.GetHardLimit()); + if (memoryStats.HasHardLimit()) { + SystemStateInfo.SetMemoryLimit(memoryStats.GetHardLimit()); + } else { + SystemStateInfo.ClearMemoryLimit(); } - if (MemoryStats.HasAllocatedMemory()) { - systemStateUpdate.SetMemoryUsedInAlloc(MemoryStats.GetAllocatedMemory()); + if (memoryStats.HasAllocatedMemory()) { + SystemStateInfo.SetMemoryUsedInAlloc(memoryStats.GetAllocatedMemory()); + } else { + SystemStateInfo.ClearMemoryUsedInAlloc(); } - - // Note: is rendered in UI as 'Caches', so let's pass aggregated caches stats (not only Shared Cache stats) - if (MemoryStats.HasConsumersConsumption()) { - systemStateUpdate.MutableSharedCacheStats()->SetUsedBytes(MemoryStats.GetConsumersConsumption()); + if (memoryStats.HasSharedCacheConsumption()) { + SystemStateInfo.MutableSharedCacheStats()->SetUsedBytes(memoryStats.GetSharedCacheConsumption()); + } else { + SystemStateInfo.MutableSharedCacheStats()->ClearUsedBytes(); } - if (MemoryStats.HasConsumersLimit()) { - systemStateUpdate.MutableSharedCacheStats()->SetLimitBytes(MemoryStats.GetConsumersLimit()); + if (memoryStats.HasSharedCacheLimit()) { + SystemStateInfo.MutableSharedCacheStats()->SetLimitBytes(memoryStats.GetSharedCacheLimit()); + } else { + SystemStateInfo.MutableSharedCacheStats()->ClearLimitBytes(); } - if (CheckedMerge(SystemStateInfo, systemStateUpdate)) { - SystemStateInfo.SetChangeTime(ctx.Now().MilliSeconds()); - } + SystemStateInfo.MutableMemoryStats()->Swap(&ev->Get()->Record); + + // Note: there is no big reason (and an easy way) to compare the previous and the new memory stats + // and allocated memory stat is expected to change every time + // so always update change time unconditionally + SystemStateInfo.SetChangeTime(ctx.Now().MilliSeconds()); } void Handle(TEvWhiteboard::TEvSystemStateAddEndpoint::TPtr &ev, const TActorContext &ctx) { |