diff --git a/ydb/library/yql/dq/actors/compute/dq_async_compute_actor.cpp b/ydb/library/yql/dq/actors/compute/dq_async_compute_actor.cpp index 07e2c5606a92..ef5d7768cff6 100644 --- a/ydb/library/yql/dq/actors/compute/dq_async_compute_actor.cpp +++ b/ydb/library/yql/dq/actors/compute/dq_async_compute_actor.cpp @@ -509,7 +509,7 @@ class TDqAsyncComputeActor : public TDqComputeActorBase } ProcessOutputsImpl(status); if (status == ERunStatus::Finished) { - ReportStats(TInstant::Now()); + ReportStats(TInstant::Now(), ESendStats::IfPossible); } if (UseCpuQuota()) { diff --git a/ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h b/ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h index fd397b34951d..bfd081e4ccd5 100644 --- a/ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h +++ b/ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h @@ -318,7 +318,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped MemoryQuota->TryShrinkMemory(alloc); } - ReportStats(TInstant::Now()); + ReportStats(TInstant::Now(), ESendStats::IfPossible); } if (Terminated) { TaskRunner.Reset(); @@ -1238,10 +1238,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped const auto maxInterval = RuntimeSettings.ReportStatsSettings->MaxInterval; this->Schedule(maxInterval, new NActors::TEvents::TEvWakeup(EEvWakeupTag::PeriodicStatsTag)); - auto now = NActors::TActivationContext::Now(); - if (now - LastSendStatsTime >= maxInterval) { - ReportStats(now); - } + ReportStats(NActors::TActivationContext::Now(), ESendStats::IfRequired); break; } default: @@ -2178,15 +2175,26 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped } protected: - void ReportStats(TInstant now) { + enum class ESendStats { + IfPossible, + IfRequired + }; + void ReportStats(TInstant now, ESendStats condition) { if (!RuntimeSettings.ReportStatsSettings) { return; } - - if (now - LastSendStatsTime < RuntimeSettings.ReportStatsSettings->MinInterval) { - return; + auto dT = now - LastSendStatsTime; + switch(condition) { + case ESendStats::IfPossible: + if (dT < RuntimeSettings.ReportStatsSettings->MinInterval) { + return; + } + break; + case ESendStats::IfRequired: + if (dT < RuntimeSettings.ReportStatsSettings->MaxInterval) { + return; + } } - auto evState = std::make_unique(); evState->Record.SetState(NDqProto::COMPUTE_STATE_EXECUTING); evState->Record.SetTaskId(Task.GetId());