From f832758b8d5cfc0c3d1d1513ad43643e0876800b Mon Sep 17 00:00:00 2001 From: Oleg Shatov Date: Mon, 5 Feb 2024 09:03:52 +0000 Subject: [PATCH 1/3] Removed obsolete controls --- .../common_controls/tracing_control.cpp | 62 ----------------- .../control/common_controls/tracing_control.h | 33 ---------- ydb/core/control/common_controls/ya.make | 13 ---- .../control/immediate_control_board_sampler.h | 25 ------- .../immediate_control_board_throttler.h | 66 ------------------- ydb/core/control/ya.make | 6 -- ydb/core/grpc_services/grpc_request_proxy.cpp | 1 - ydb/core/keyvalue/ya.make | 1 - ydb/core/protos/config.proto | 50 -------------- 9 files changed, 257 deletions(-) delete mode 100644 ydb/core/control/common_controls/tracing_control.cpp delete mode 100644 ydb/core/control/common_controls/tracing_control.h delete mode 100644 ydb/core/control/common_controls/ya.make delete mode 100644 ydb/core/control/immediate_control_board_sampler.h delete mode 100644 ydb/core/control/immediate_control_board_throttler.h diff --git a/ydb/core/control/common_controls/tracing_control.cpp b/ydb/core/control/common_controls/tracing_control.cpp deleted file mode 100644 index 536738dd289f..000000000000 --- a/ydb/core/control/common_controls/tracing_control.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "tracing_control.h" - -#include -#include -#include - -namespace NKikimr { - -namespace { - -const NKikimrConfig::TImmediateControlOptions& GetImmediateControlOptionsForField( - const google::protobuf::Descriptor& descriptor, TString fieldName) { - auto field = descriptor.FindFieldByName(fieldName); - Y_ABORT_UNLESS(field); - auto& fieldOptions = field->options(); - return fieldOptions.GetExtension(NKikimrConfig::ControlOptions); -} - -TThrottler CreateThrottler(TIntrusivePtr& icb, TIntrusivePtr timeProvider, TString domain) { - TControlWrapper maxRatePerMinute; - TControlWrapper maxBurst; - - const std::array, 2> controls = {{ - {maxRatePerMinute, "MaxRatePerMinute"}, - {maxBurst, "MaxBurst"}, - }}; - const auto& throttlingOptions = *NKikimrConfig::TImmediateControlsConfig::TTracingControls::TSamplingThrottlingOptions::TThrottlingOptions::descriptor(); - for (auto& [control, fieldName] : controls) { - const auto& controlOptions = GetImmediateControlOptionsForField(throttlingOptions, TString(fieldName)); - - control.Reset(controlOptions.GetDefaultValue(), controlOptions.GetMinValue(), controlOptions.GetMaxValue()); - icb->RegisterSharedControl(control, domain + "." + fieldName); - } - - return TThrottler(std::move(maxRatePerMinute), std::move(maxBurst), std::move(timeProvider)); -} - -} - -TTracingControl::TTracingControl(TIntrusivePtr& icb, TIntrusivePtr timeProvider, - TIntrusivePtr& randomProvider, TString controlDomain) -{ - SampledThrottler = CreateThrottler(icb, timeProvider, controlDomain + ".SampledThrottling"); - ExternalThrottler = CreateThrottler(icb, timeProvider, controlDomain + ".ExternalThrottling"); - - TControlWrapper samplingPPM; - const std::array, 2> controls = {{ - {samplingPPM, "PPM"}, - {SampledLevel, "Level"}, - }}; - - const auto& samplingOptions = *NKikimrConfig::TImmediateControlsConfig::TTracingControls::TSamplingThrottlingOptions::TSamplingOptions::descriptor(); - for (auto [control, name] : controls) { - const auto& controlOptions = GetImmediateControlOptionsForField(samplingOptions, TString(name)); - control.Reset(controlOptions.GetDefaultValue(), controlOptions.GetMinValue(), controlOptions.GetMaxValue()); - icb->RegisterSharedControl(control, controlDomain + ".Sampling." + name); - } - - Sampler = TSampler(std::move(samplingPPM), randomProvider->GenRand64()); -} - -} // namespace NKikimr diff --git a/ydb/core/control/common_controls/tracing_control.h b/ydb/core/control/common_controls/tracing_control.h deleted file mode 100644 index 56b7f45966da..000000000000 --- a/ydb/core/control/common_controls/tracing_control.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace NKikimr { - -class TTracingControl { -public: - TTracingControl(TIntrusivePtr& icb, TIntrusivePtr timeProvider, - TIntrusivePtr& randomProvider, TString controlDomain); - - bool SampleThrottle() { - return Sampler.Sample() && !SampledThrottler.Throttle(); - } - - bool ThrottleExternal() { - return ExternalThrottler.Throttle(); - } - - ui8 SampledVerbosity() const { - return SampledLevel; - } - -private: - TSampler Sampler; - TThrottler SampledThrottler; - TThrottler ExternalThrottler; - TControlWrapper SampledLevel; -}; - -} // namespace NKikimr diff --git a/ydb/core/control/common_controls/ya.make b/ydb/core/control/common_controls/ya.make deleted file mode 100644 index afc6df1f79d2..000000000000 --- a/ydb/core/control/common_controls/ya.make +++ /dev/null @@ -1,13 +0,0 @@ -LIBRARY() - -PEERDIR( - ydb/library/actors/wilson - ydb/core/protos -) - -SRCS( - tracing_control.h - tracing_control.cpp -) - -END() diff --git a/ydb/core/control/immediate_control_board_sampler.h b/ydb/core/control/immediate_control_board_sampler.h deleted file mode 100644 index e6d6784540b7..000000000000 --- a/ydb/core/control/immediate_control_board_sampler.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include - -namespace NKikimr { - -class TSampler { -public: - TSampler() : Rng(0) {} - - TSampler(TControlWrapper samplingPPM, ui64 seed) - : SamplingPPM(std::move(samplingPPM)) - , Rng(seed) - {} - - bool Sample() { - return Rng() % 1'000'000 < SamplingPPM; - } - -private: - TControlWrapper SamplingPPM; - TReallyFastRng32 Rng; -}; - -} // namespace NKikimr diff --git a/ydb/core/control/immediate_control_board_throttler.h b/ydb/core/control/immediate_control_board_throttler.h deleted file mode 100644 index c3ee83bf0f43..000000000000 --- a/ydb/core/control/immediate_control_board_throttler.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include -#include - -namespace NKikimr { - -class TThrottler { -public: - TThrottler() = default; - - TThrottler(TControlWrapper maxRatePerMinute, TControlWrapper maxBurst, - TIntrusivePtr timeProvider) - : TimeProvider(std::move(timeProvider)) - , MaxRatePerMinute(std::move(maxRatePerMinute)) - , MaxBurst(std::move(maxBurst)) - , LastUpdate(TimeProvider->Now()) - {} - - bool Throttle() { - auto maxRatePerMinute = static_cast(MaxRatePerMinute); - auto maxBurst = static_cast(MaxBurst); - auto maxTotal = maxBurst + 1; - CurrentBurst = std::min(CurrentBurst, maxTotal); - if (maxRatePerMinute == 0) { - return true; - } - - auto now = TimeProvider->Now(); - if (now < LastUpdate) { - return true; - } - - const auto deltaBetweenSends = TDuration::Minutes(1) / maxRatePerMinute; - UpdateStats(now, deltaBetweenSends); - - if (CurrentBurst < maxTotal) { - CurrentBurst += 1; - return false; - } - - return true; - } - -private: - void UpdateStats(TInstant now, TDuration deltaBetweenSends) { - i64 decrease = (now - LastUpdate) / deltaBetweenSends; - decrease = std::min(decrease, CurrentBurst); - Y_ABORT_UNLESS(decrease >= 0); - CurrentBurst -= decrease; - LastUpdate += decrease * deltaBetweenSends; - if (CurrentBurst == 0) { - LastUpdate = now; - } - } - - TIntrusivePtr TimeProvider; - - TControlWrapper MaxRatePerMinute; - TControlWrapper MaxBurst; - - TInstant LastUpdate = TInstant::Zero(); - i64 CurrentBurst = 0; -}; - -} // namespace NKikimr diff --git a/ydb/core/control/ya.make b/ydb/core/control/ya.make index 4faca2369cf5..8c1c83bff961 100644 --- a/ydb/core/control/ya.make +++ b/ydb/core/control/ya.make @@ -19,16 +19,10 @@ SRCS( immediate_control_board_impl.cpp immediate_control_board_impl.h immediate_control_board_wrapper.h - immediate_control_board_throttler.h - immediate_control_board_sampler.h ) END() -RECURSE( - common_controls -) - RECURSE_FOR_TESTS( ut ) diff --git a/ydb/core/grpc_services/grpc_request_proxy.cpp b/ydb/core/grpc_services/grpc_request_proxy.cpp index 22f9b054c518..388674a80225 100644 --- a/ydb/core/grpc_services/grpc_request_proxy.cpp +++ b/ydb/core/grpc_services/grpc_request_proxy.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/ydb/core/keyvalue/ya.make b/ydb/core/keyvalue/ya.make index 740eae043d01..3a014e31316d 100644 --- a/ydb/core/keyvalue/ya.make +++ b/ydb/core/keyvalue/ya.make @@ -45,7 +45,6 @@ PEERDIR( ydb/library/actors/protos ydb/core/base ydb/core/blobstorage/base - ydb/core/control/common_controls ydb/core/engine/minikql ydb/core/keyvalue/protos ydb/core/protos diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto index f6f06c59790d..3b90e11173bd 100644 --- a/ydb/core/protos/config.proto +++ b/ydb/core/protos/config.proto @@ -1245,61 +1245,11 @@ message TImmediateControlsConfig { DefaultValue: 8388608 }]; } - message TTracingControls { - message TSamplingThrottlingOptions { - message TThrottlingOptions { - optional uint64 MaxRatePerMinute = 1 [(ControlOptions) = { - Description: "Maximum amount of traced requests per minute", - MinValue: 0, - MaxValue: 300, - DefaultValue: 0, - }]; - optional uint64 MaxBurst = 2 [(ControlOptions) = { - Description: "Maximum burst of traced events", - MinValue: 0, - MaxValue: 300, - DefaultValue: 0, - }]; - } - - message TSamplingOptions { - optional uint64 PPM = 1 [(ControlOptions) = { - Description: "Average amount of sampled requests per one million", - MinValue: 0, - MaxValue: 1000000, - DefaultValue: 0, - }]; - optional uint64 Level = 2 [(ControlOptions) = { - Description: "Tracing level of sampled requests", - MinValue: 1, - MaxValue: 15, - DefaultValue: 15, - }]; - } - - optional TSamplingOptions Sampling = 1; - optional TThrottlingOptions SampledThrottling = 2; - optional TThrottlingOptions ExternalThrottling = 3; - } - - message TKeyValue { - optional TSamplingThrottlingOptions AcquireLock = 1; - optional TSamplingThrottlingOptions ExecuteTransaction = 2; - optional TSamplingThrottlingOptions Read = 3; - optional TSamplingThrottlingOptions ReadRange = 4; - optional TSamplingThrottlingOptions ListRange = 5; - optional TSamplingThrottlingOptions GetStorageChannelStatus = 6; - } - - optional TKeyValue KeyValue = 1; - } - optional TDataShardControls DataShardControls = 1; optional TTxLimitControls TxLimitControls = 2; optional TCoordinatorControls CoordinatorControls = 3; optional TSchemeShardControls SchemeShardControls = 4; optional TTCMallocControls TCMallocControls = 5; - optional TTracingControls TracingControls = 6; }; message TMeteringConfig { From 2af0347456d4603790f7160890257d6422b81e0a Mon Sep 17 00:00:00 2001 From: Oleg Shatov Date: Mon, 5 Feb 2024 11:39:12 +0000 Subject: [PATCH 2/3] Fix of json_proxy_proto.h --- ydb/core/cms/json_proxy_proto.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ydb/core/cms/json_proxy_proto.h b/ydb/core/cms/json_proxy_proto.h index 4844919de311..a422cbe8292e 100644 --- a/ydb/core/cms/json_proxy_proto.h +++ b/ydb/core/cms/json_proxy_proto.h @@ -76,16 +76,6 @@ class TJsonProxyProto : public TActorBootstrapped { return ReplyWithTypeDescription(*NKikimrConfig::TImmediateControlsConfig::TSchemeShardControls::descriptor(), ctx); else if (name == ".NKikimrConfig.TImmediateControlsConfig.TTCMallocControls") return ReplyWithTypeDescription(*NKikimrConfig::TImmediateControlsConfig::TTCMallocControls::descriptor(), ctx); - else if (name == ".NKikimrConfig.TImmediateControlsConfig.TTracingControls") - return ReplyWithTypeDescription(*NKikimrConfig::TImmediateControlsConfig::TTracingControls::descriptor(), ctx); - else if (name == ".NKikimrConfig.TImmediateControlsConfig.TTracingControls.TSamplingThrottlingOptions") - return ReplyWithTypeDescription(*NKikimrConfig::TImmediateControlsConfig::TTracingControls::TSamplingThrottlingOptions::descriptor(), ctx); - else if (name == ".NKikimrConfig.TImmediateControlsConfig.TTracingControls.TSamplingThrottlingOptions.TThrottlingOptions") - return ReplyWithTypeDescription(*NKikimrConfig::TImmediateControlsConfig::TTracingControls::TSamplingThrottlingOptions::TThrottlingOptions::descriptor(), ctx); - else if (name == ".NKikimrConfig.TImmediateControlsConfig.TTracingControls.TSamplingThrottlingOptions.TSamplingOptions") - return ReplyWithTypeDescription(*NKikimrConfig::TImmediateControlsConfig::TTracingControls::TSamplingThrottlingOptions::TSamplingOptions::descriptor(), ctx); - else if (name == ".NKikimrConfig.TImmediateControlsConfig.TTracingControls.TKeyValue") - return ReplyWithTypeDescription(*NKikimrConfig::TImmediateControlsConfig::TTracingControls::TKeyValue::descriptor(), ctx); } ctx.Send(RequestEvent->Sender, From 271682c6676f88235eb8597784285d6629138c70 Mon Sep 17 00:00:00 2001 From: Oleg Shatov Date: Tue, 6 Feb 2024 07:59:27 +0000 Subject: [PATCH 3/3] Reserved deleted field id --- ydb/core/protos/config.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto index 3b90e11173bd..5e2c7e273593 100644 --- a/ydb/core/protos/config.proto +++ b/ydb/core/protos/config.proto @@ -1250,6 +1250,7 @@ message TImmediateControlsConfig { optional TCoordinatorControls CoordinatorControls = 3; optional TSchemeShardControls SchemeShardControls = 4; optional TTCMallocControls TCMallocControls = 5; + reserved 6; }; message TMeteringConfig {