-
Notifications
You must be signed in to change notification settings - Fork 741
Improve CA introspection #30263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
PavelEfarinov
merged 2 commits into
ydb-platform:main
from
Hor911:compute_actor_introspection
Dec 10, 2025
Merged
Improve CA introspection #30263
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -406,6 +406,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
| } | ||
|
|
||
| ProcessOutputsState.LastRunStatus = status; | ||
| ProcessOutputsState.LastRunTime = TInstant::Now(); | ||
|
|
||
| for (auto& entry : OutputChannelsMap) { | ||
| const ui64 channelId = entry.first; | ||
|
|
@@ -855,25 +856,29 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
|
|
||
| protected: | ||
| struct TInputChannelInfo { | ||
| ui32 InputIndex; | ||
| TString LogPrefix; | ||
| ui64 ChannelId; | ||
| ui32 SrcStageId; | ||
| IDqInputChannel::TPtr Channel; | ||
| bool HasPeer = false; | ||
| NActors::TActorId PeerId; | ||
| const NDqProto::EWatermarksMode WatermarksMode; | ||
| const TDuration WatermarksIdleTimeout = TDuration::Max(); | ||
| std::optional<NDqProto::TCheckpoint> PendingCheckpoint; | ||
| const NDqProto::ECheckpointingMode CheckpointingMode; | ||
| i64 FreeSpace = 0; | ||
|
|
||
| explicit TInputChannelInfo( | ||
| ui32 inputIndex, | ||
| const TString& logPrefix, | ||
| ui64 channelId, | ||
| ui32 srcStageId, | ||
| NDqProto::EWatermarksMode watermarksMode, | ||
| NDqProto::ECheckpointingMode checkpointingMode, | ||
| TDuration watermarksIdleTimeout) | ||
| : LogPrefix(logPrefix) | ||
| : InputIndex(inputIndex) | ||
| , LogPrefix(logPrefix) | ||
| , ChannelId(channelId) | ||
| , SrcStageId(srcStageId) | ||
| , WatermarksMode(watermarksMode) | ||
|
|
@@ -919,6 +924,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
| ui32 DstStageId; | ||
| IDqOutputChannel::TPtr Channel; | ||
| bool HasPeer = false; | ||
| NActors::TActorId PeerId; | ||
| bool Finished = false; // != Channel->IsFinished() // If channel is in finished state, it sends only checkpoints. | ||
| bool EarlyFinish = false; | ||
| bool PopStarted = false; | ||
|
|
@@ -1089,6 +1095,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
|
|
||
| Channels->SetInputChannelPeer(channelUpdate.GetId(), peer); | ||
| inputChannel->HasPeer = true; | ||
| inputChannel->PeerId = peer; | ||
|
|
||
| continue; | ||
| } | ||
|
|
@@ -1101,6 +1108,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
|
|
||
| Channels->SetOutputChannelPeer(channelUpdate.GetId(), peer); | ||
| outputChannel->HasPeer = true; | ||
| outputChannel->PeerId = peer; | ||
| if (outputChannel->Channel) { | ||
| outputChannel->Channel->UpdateSettings({.IsLocalChannel = peer.NodeId() == this->SelfId().NodeId()}); | ||
| } | ||
|
|
@@ -1276,8 +1284,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
| void MonitoringExtra(TStringStream&) { | ||
| } | ||
|
|
||
| void OnMonitoringPage(NActors::NMon::TEvHttpInfo::TPtr& ev) { | ||
| TStringStream html; | ||
| void DumpForMonitoring(TStringStream& html) { | ||
| static_cast<TDerived*>(this)->MonitoringExtra(html); | ||
|
|
||
| #define DUMP(P, X,...) html << #X ": " << P.X __VA_ARGS__ << "<br />" | ||
|
|
@@ -1533,8 +1540,181 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
| } | ||
| #undef DUMP | ||
| #undef DUMP_PREFIXED | ||
| } | ||
|
|
||
| void DefaultMonitoringPage(TStringStream& str) { | ||
| HTML(str) { | ||
| PRE() { | ||
| str << "TDqComputeActorBase, SelfId=" << this->SelfId() << ' '; | ||
| HREF(TStringBuilder() << "?ca=" << this->SelfId() << "&view=dump") { | ||
| str << "Dump"; | ||
| } | ||
| str << ' '; | ||
| HREF(TStringBuilder() << "?ca=" << this->SelfId() << "&view=run") { | ||
| str << "Run"; | ||
| } | ||
| str << Endl; | ||
|
|
||
| COLLAPSED_BUTTON_CONTENT("ProcessOutputsState", TStringBuilder() << "ProcessOutputsState: " << ProcessOutputsState.LastRunTime << ' ' << ProcessOutputsState.LastRunStatus) { | ||
| str << " Inflight: " << ProcessOutputsState.Inflight << Endl; | ||
| str << " ChannelsReady: " << ProcessOutputsState.ChannelsReady << Endl; | ||
| str << " HasDataToSend: " << ProcessOutputsState.HasDataToSend << Endl; | ||
| str << " DataWasSent: " << ProcessOutputsState.DataWasSent << Endl; | ||
| str << " AllOutputsFinished: " << ProcessOutputsState.AllOutputsFinished << Endl; | ||
| str << " LastRunStatus: " << ProcessOutputsState.LastRunStatus << Endl; | ||
| str << " LastRunTime: " << ProcessOutputsState.LastRunTime << Endl; | ||
| str << " LastPopReturnedNoData: " << ProcessOutputsState.LastPopReturnedNoData << Endl; | ||
| } | ||
|
|
||
| str << Endl << "Input Channels:" << Endl; | ||
| TABLE_SORTABLE_CLASS("table table-condensed") { | ||
| TABLEHEAD() { | ||
| TABLER() { | ||
| TABLEH_ATTRS({{"title", "ChannelId"}}) {str << "Id";} | ||
| TABLEH_ATTRS({{"title", "SrcStageId"}}) {str << "Src";} | ||
| TABLEH_ATTRS({{"title", "InputIndex"}}) {str << "Idx";} | ||
| TABLEH() {str << "PeerId";} | ||
| TABLEH_ATTRS({{"title", "IsFinished"}}) {str << "F";} | ||
| TABLEH() {str << "Push.Bytes";} | ||
| TABLEH() {str << "Push.Rows";} | ||
| TABLEH() {str << "Pop.Bytes";} | ||
| TABLEH() {str << "Pop.Rows";} | ||
| } | ||
| } | ||
| TABLEBODY() { | ||
| for (const auto& [id, info]: InputChannelsMap) { | ||
| TABLER() { | ||
| TABLED() {str << info.ChannelId;} | ||
| TABLED() {str << info.SrcStageId;} | ||
| TABLED() {str << info.InputIndex;} | ||
| TABLED() { | ||
| if (info.HasPeer) { | ||
| HREF(TStringBuilder() << "/node/" << info.PeerId.NodeId() << "/actors/kqp_node?ca=" << info.PeerId) { | ||
| str << info.PeerId; | ||
| } | ||
| } else { | ||
| str << "N/A"; | ||
| } | ||
| } | ||
|
|
||
| this->Send(ev->Sender, new NActors::NMon::TEvHttpInfoRes(html.Str())); | ||
| auto channel = info.Channel; | ||
| if (!channel) { | ||
| auto stats = GetTaskRunnerStats(); | ||
| if (stats) { | ||
| auto stageIt = stats->InputChannels.find(info.SrcStageId); | ||
| if (stageIt != stats->InputChannels.end()) { | ||
| auto channelIt = stageIt->second.find(info.ChannelId); | ||
| if (channelIt != stageIt->second.end()) { | ||
| channel = channelIt->second; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (channel) { | ||
| TABLED() {str << channel->IsFinished();} | ||
| auto& pushStats = channel->GetPushStats(); | ||
| TABLED() {str << pushStats.Bytes;} | ||
| TABLED() {str << pushStats.Rows;} | ||
| auto& popStats = channel->GetPopStats(); | ||
| TABLED() {str << popStats.Bytes;} | ||
| TABLED() {str << popStats.Rows;} | ||
| } else { | ||
| TABLED() {str << "N/A";} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Угу, может быть плохо, надо тестить |
||
| TABLED() {str << "N/A";} | ||
| TABLED() {str << "N/A";} | ||
| TABLED() {str << "N/A";} | ||
| TABLED() {str << "N/A";} | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| str << Endl << "Output Channels:" << Endl; | ||
| TABLE_SORTABLE_CLASS("table table-condensed") { | ||
| TABLEHEAD() { | ||
| TABLER() { | ||
| TABLEH_ATTRS({{"title", "ChannelId"}}) {str << "Id";} | ||
| TABLEH_ATTRS({{"title", "DstStageId"}}) {str << "Dst";} | ||
| TABLEH() {str << "PeerId";} | ||
| TABLEH_ATTRS({{"title", "Finished"}}) {str << "F";} | ||
| TABLEH_ATTRS({{"title", "EarlyFinish"}}) {str << "EF";} | ||
| TABLEH() {str << "Push.Bytes";} | ||
| TABLEH() {str << "Push.Rows";} | ||
| TABLEH() {str << "Pop.Bytes";} | ||
| TABLEH() {str << "Pop.Rows";} | ||
| } | ||
| } | ||
| TABLEBODY() { | ||
| for (const auto& [id, info]: OutputChannelsMap) { | ||
| TABLER() { | ||
| TABLED() {str << info.ChannelId;} | ||
| TABLED() {str << info.DstStageId;} | ||
| TABLED() { | ||
| if (info.HasPeer) { | ||
| HREF(TStringBuilder() << "/node/" << info.PeerId.NodeId() << "/actors/kqp_node?ca=" << info.PeerId) { | ||
| str << info.PeerId; | ||
| } | ||
| } else { | ||
| str << "N/A"; | ||
| } | ||
| } | ||
| TABLED() {str << info.Finished;} | ||
| TABLED() {str << info.EarlyFinish;} | ||
|
|
||
| auto channel = info.Channel; | ||
| if (!channel) { | ||
| auto stats = GetTaskRunnerStats(); | ||
| if (stats) { | ||
| auto stageIt = stats->OutputChannels.find(info.DstStageId); | ||
| if (stageIt != stats->OutputChannels.end()) { | ||
| auto channelIt = stageIt->second.find(info.ChannelId); | ||
| if (channelIt != stageIt->second.end()) { | ||
| channel = channelIt->second; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (channel) { | ||
| auto& pushStats = channel->GetPushStats(); | ||
| TABLED() {str << pushStats.Bytes;} | ||
| TABLED() {str << pushStats.Rows;} | ||
| auto& popStats = channel->GetPopStats(); | ||
| TABLED() {str << popStats.Bytes;} | ||
| TABLED() {str << popStats.Rows;} | ||
| } else { | ||
| TABLED() {str << "N/A";} | ||
| TABLED() {str << "N/A";} | ||
| TABLED() {str << "N/A";} | ||
| TABLED() {str << "N/A";} | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void OnMonitoringPage(NActors::NMon::TEvHttpInfo::TPtr& ev) { | ||
| TStringStream str; | ||
|
|
||
| const TCgiParameters &cgi = ev->Get()->Request.GetParams(); | ||
| auto view = cgi.Get("view"); | ||
| if (view == "dump") { | ||
| DumpForMonitoring(str); | ||
| } else if (view == "run") { | ||
| if (this->Running) { | ||
| this->DoExecute(); | ||
| } | ||
| DefaultMonitoringPage(str); | ||
| } else { | ||
| DefaultMonitoringPage(str); | ||
| } | ||
|
|
||
| this->Send(ev->Sender, new NActors::NMon::TEvHttpInfoRes(str.Str())); | ||
| } | ||
|
|
||
| protected: | ||
|
|
@@ -1930,6 +2110,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
| auto result = InputChannelsMap.emplace( | ||
| channel.GetId(), | ||
| TInputChannelInfo( | ||
| i, | ||
| LogPrefix, | ||
| channel.GetId(), | ||
| channel.GetSrcStageId(), | ||
|
|
@@ -1967,7 +2148,10 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
| for (auto& channel : outputDesc.GetChannels()) { | ||
| TOutputChannelInfo outputChannel(channel.GetId(), channel.GetDstStageId()); | ||
| outputChannel.HasPeer = channel.GetDstEndpoint().HasActorId(); | ||
| outputChannel.IsTransformOutput = outputDesc.HasTransform(); | ||
| if (outputChannel.HasPeer) { | ||
| outputChannel.PeerId = NActors::ActorIdFromProto(channel.GetDstEndpoint().GetActorId()); | ||
| } | ||
| outputChannel.IsTransformOutput = outputDesc.HasTransform(); | ||
| outputChannel.WatermarksMode = channel.GetWatermarksMode(); | ||
|
|
||
| if (Y_UNLIKELY(RuntimeSettings.StatsMode >= NDqProto::DQ_STATS_MODE_PROFILE)) { | ||
|
|
@@ -2366,6 +2550,7 @@ class TDqComputeActorBase : public NActors::TActorBootstrapped<TDerived> | |
| bool DataWasSent = false; | ||
| bool AllOutputsFinished = true; | ||
| ERunStatus LastRunStatus = ERunStatus::PendingInput; | ||
| TInstant LastRunTime; | ||
| bool LastPopReturnedNoData = false; | ||
| }; | ||
| TProcessOutputsState ProcessOutputsState; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не уверен, что всё целиком нужно заворачивать в
<pre>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У нас в таком стиле много другие страниц внутри YDB сделано, поэтому я оттуда скопировал, но можно обсудить и покрутить, как лучше будет выглядеть