diff --git a/ydb/core/tablet/resource_broker.cpp b/ydb/core/tablet/resource_broker.cpp index 05f4f79b772d..29cb3dc06072 100644 --- a/ydb/core/tablet/resource_broker.cpp +++ b/ydb/core/tablet/resource_broker.cpp @@ -1302,7 +1302,7 @@ NKikimrResourceBroker::TResourceBrokerConfig MakeDefaultConfig() const ui64 DefaultQueueCPU = 2; const ui64 KqpRmQueueCPU = 4; - const ui64 TotalCPU = 20; + const ui64 TotalCPU = 256; // means unlimited // Note: these memory limits will be overwritten by MemoryController const ui64 KqpRmQueueMemory = 10_GB; diff --git a/ydb/core/tablet/resource_broker_ut.cpp b/ydb/core/tablet/resource_broker_ut.cpp index aa2ba8131c08..7c3157e5b973 100644 --- a/ydb/core/tablet/resource_broker_ut.cpp +++ b/ydb/core/tablet/resource_broker_ut.cpp @@ -15,13 +15,13 @@ namespace NKikimr { using namespace NKikimrResourceBroker; using namespace NResourceBroker; -static void SetupLogging(TTestActorRuntime& runtime) { +static void SetupLogging(TTestActorRuntime& runtime) +{ NActors::NLog::EPriority priority = ENABLE_DETAILED_RESOURCE_BROKER_LOG ? NLog::PRI_DEBUG : NLog::PRI_ERROR; runtime.SetLogPriority(NKikimrServices::RESOURCE_BROKER, priority); } -static NKikimrResourceBroker::TResourceBrokerConfig -MakeTestConfig() +static NKikimrResourceBroker::TResourceBrokerConfig MakeTestConfig() { NKikimrResourceBroker::TResourceBrokerConfig config; @@ -71,16 +71,14 @@ MakeTestConfig() return config; } -static void -WaitForBootstrap(TTestActorRuntime &runtime) +static void WaitForBootstrap(TTestActorRuntime &runtime) { TDispatchOptions options; options.FinalEvents.emplace_back(TEvents::TSystem::Bootstrap, 1); UNIT_ASSERT(runtime.DispatchEvents(options)); } -static void -SubmitTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, +static void SubmitTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id, ui64 cpu, ui64 memory, const TString &type, ui32 priority, TIntrusivePtr cookie = nullptr) { @@ -94,8 +92,7 @@ SubmitTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, runtime.Send(new IEventHandle(broker, sender, event.Release())); } -static void -UpdateTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, +static void UpdateTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id, ui64 cpu, ui64 memory, ui32 priority, const TString &type, bool resubmit = false) { @@ -107,8 +104,7 @@ UpdateTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, runtime.Send(new IEventHandle(broker, sender, event.Release())); } -static void -UpdateTaskCookie(TTestActorRuntime &runtime, TActorId broker, TActorId sender, +static void UpdateTaskCookie(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id, TIntrusivePtr cookie) { TAutoPtr event @@ -117,8 +113,7 @@ UpdateTaskCookie(TTestActorRuntime &runtime, TActorId broker, TActorId sender, runtime.Send(new IEventHandle(broker, sender, event.Release())); } -static void -RemoveTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id) +static void RemoveTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id) { TAutoPtr event = new TEvResourceBroker::TEvRemoveTask(id); @@ -126,8 +121,7 @@ RemoveTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id runtime.Send(new IEventHandle(broker, sender, event.Release())); } -static void -FinishTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id) +static void FinishTask(TTestActorRuntime &runtime, TActorId broker, TActorId sender, ui64 id) { TAutoPtr event = new TEvResourceBroker::TEvFinishTask(id); @@ -147,8 +141,7 @@ WaitForResourceAllocation(TTestActorRuntime &runtime, ui64 id, return reply->TaskId; } -static void -WaitForError(TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::ECode code, +static void WaitForError(TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::ECode code, TIntrusivePtr cookie = nullptr) { TAutoPtr handle; @@ -158,8 +151,7 @@ WaitForError(TTestActorRuntime &runtime, ui64 id, TEvResourceBroker::TStatus::EC UNIT_ASSERT_VALUES_EQUAL(reply->Cookie, cookie); } -static void -CheckCounters(::NMonitoring::TDynamicCounterPtr counters, const TString &group, const TString &name, +static void CheckCounters(::NMonitoring::TDynamicCounterPtr counters, const TString &group, const TString &name, ui64 cpu, ui64 memory, ui64 finished, ui64 enqueued, ui64 infly) { auto g = counters->GetSubgroup(group, name); @@ -185,14 +177,14 @@ static void CheckConfigure(TTestActorRuntime &runtime, TActorId broker, TActorId UNIT_ASSERT_VALUES_EQUAL((int)rec.GetSuccess(), (int)success); } -static -TIntrusivePtr GetInstantResourceBroker(TTestActorRuntime &runtime, TActorId broker, TActorId sender) { +static TIntrusivePtr GetInstantResourceBroker(TTestActorRuntime &runtime, TActorId broker, TActorId sender) { runtime.Send(new IEventHandle(broker, sender, new TEvResourceBroker::TEvResourceBrokerRequest)); auto answer = runtime.GrabEdgeEvent(sender); return answer->Get()->ResourceBroker; } Y_UNIT_TEST_SUITE(TResourceBroker) { + Y_UNIT_TEST(TestErrors) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -894,6 +886,7 @@ Y_UNIT_TEST_SUITE(TResourceBroker) { }; Y_UNIT_TEST_SUITE(TResourceBrokerInstant) { + Y_UNIT_TEST(Test) { TTestBasicRuntime runtime; SetupTabletServices(runtime); @@ -1007,6 +1000,7 @@ Y_UNIT_TEST_SUITE(TResourceBrokerInstant) { CheckCounters(counters, "queue", "total", 210, 320, 1, 0, 2); } } + }; Y_UNIT_TEST_SUITE(TResourceBrokerConfig) { @@ -1130,6 +1124,21 @@ Y_UNIT_TEST_SUITE(TResourceBrokerConfig) { UNIT_ASSERT_VALUES_EQUAL(config.ShortDebugString(), "ResourceLimit { Cpu: 20 Memory: 2048 }"); } + Y_UNIT_TEST(DefaultConfig) { + auto config = MakeDefaultConfig(); + + Cerr << config.DebugString() << Endl; + + ui64 queuesCpu = 0; + for (const auto& q : config.GetQueues()) { + queuesCpu += q.GetLimit().GetCpu(); + } + Cerr << "Total queues cpu: " << queuesCpu; + + // see https://github.com/ydb-platform/ydb/issues/18513 + UNIT_ASSERT_LE(queuesCpu, config.GetResourceLimit().GetCpu()); + } + } // TResourceBrokerConfig } // NKikimr