Skip to content

Commit

Permalink
YQL-17542 clarify send stats condition in compute actor (ydb-platform…
Browse files Browse the repository at this point in the history
  • Loading branch information
zverevgeny authored Jan 22, 2024
1 parent 34c493d commit 477e168
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class TDqAsyncComputeActor : public TDqComputeActorBase<TDqAsyncComputeActor>
}
ProcessOutputsImpl(status);
if (status == ERunStatus::Finished) {
ReportStats(TInstant::Now());
ReportStats(TInstant::Now(), ESendStats::IfPossible);
}

if (UseCpuQuota()) {
Expand Down
28 changes: 18 additions & 10 deletions ydb/library/yql/dq/actors/compute/dq_compute_actor_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived>
MemoryQuota->TryShrinkMemory(alloc);
}

ReportStats(TInstant::Now());
ReportStats(TInstant::Now(), ESendStats::IfPossible);
}
if (Terminated) {
TaskRunner.Reset();
Expand Down Expand Up @@ -1238,10 +1238,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived>
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:
Expand Down Expand Up @@ -2178,15 +2175,26 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived>
}

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<TEvDqCompute::TEvState>();
evState->Record.SetState(NDqProto::COMPUTE_STATE_EXECUTING);
evState->Record.SetTaskId(Task.GetId());
Expand Down

0 comments on commit 477e168

Please sign in to comment.