@@ -181,6 +181,7 @@ class TJsonNodes : public TViewerPipeClient {
181
181
ui32 SpaceUsageProblem = 90 ; // %
182
182
bool OffloadMerge = true ;
183
183
size_t OffloadMergeAttempts = 2 ;
184
+ size_t OffloadMergeBatchSize = 200 ;
184
185
185
186
using TGroupSortKey = std::variant<TString, ui64, float , int >;
186
187
@@ -748,6 +749,8 @@ class TJsonNodes : public TViewerPipeClient {
748
749
std::vector<TNodeGroup> NodeGroups;
749
750
std::unordered_map<TNodeId, TNode*> NodesByNodeId;
750
751
std::unordered_map<TNodeId, TNodeBatch> NodeBatches;
752
+ std::vector<TNodeBatch> OriginalNodeBatches;
753
+ bool DumpOriginalNodeBatches = false ;
751
754
752
755
TFieldsType FieldsRequired;
753
756
TFieldsType FieldsAvailable;
@@ -953,8 +956,10 @@ class TJsonNodes : public TViewerPipeClient {
953
956
}
954
957
}
955
958
956
- OffloadMerge = FromStringWithDefault<bool >(params.Get (" offload_merge" ), OffloadMerge);
957
- OffloadMergeAttempts = FromStringWithDefault<bool >(params.Get (" offload_merge_attempts" ), OffloadMergeAttempts);
959
+ OffloadMerge = FromStringWithDefault (params.Get (" offload_merge" ), OffloadMerge);
960
+ OffloadMergeAttempts = FromStringWithDefault (params.Get (" offload_merge_attempts" ), OffloadMergeAttempts);
961
+ OffloadMergeBatchSize = FromStringWithDefault (params.Get (" offload_merge_batch_size" ), OffloadMergeBatchSize);
962
+ DumpOriginalNodeBatches = FromStringWithDefault (params.Get (" dump_original_node_batches" ), DumpOriginalNodeBatches);
958
963
Direct = FromStringWithDefault<bool >(params.Get (" direct" ), Direct);
959
964
TString filterStoragePool = params.Get (" pool" );
960
965
if (filterStoragePool.empty ()) {
@@ -1078,6 +1083,9 @@ class TJsonNodes : public TViewerPipeClient {
1078
1083
request->Record .AddFieldsRequired (-1 );
1079
1084
NodeStateResponse = MakeWhiteboardRequest (TActivationContext::ActorSystem ()->NodeId , request.release ());
1080
1085
}
1086
+ if (!FilterDatabase && OffloadMerge && FieldsNeeded (FieldsSystemState)) {
1087
+ FieldsRequired.set (+ENodeFields::SubDomainKey);
1088
+ }
1081
1089
if (!FilterStoragePools.empty () || !FilterGroupIds.empty ()) {
1082
1090
FilterDatabase = false ; // we disable database filter if we're filtering by pool or group
1083
1091
}
@@ -1571,8 +1579,6 @@ class TJsonNodes : public TViewerPipeClient {
1571
1579
ApplyLimit ();
1572
1580
}
1573
1581
1574
- static constexpr size_t BATCH_SIZE = 200 ;
1575
-
1576
1582
void BuildCandidates (TNodeBatch& batch, std::vector<TNode*>& candidates) {
1577
1583
auto itCandidate = candidates.begin ();
1578
1584
for (; itCandidate != candidates.end () && batch.NodesToAskFor .size () < OffloadMergeAttempts; ++itCandidate) {
@@ -1591,9 +1597,9 @@ class TJsonNodes : public TViewerPipeClient {
1591
1597
std::sort (candidates.begin (), candidates.end (), [](TNode* a, TNode* b) {
1592
1598
return a->GetCandidateScore () > b->GetCandidateScore ();
1593
1599
});
1594
- while (nodeBatch.NodesToAskAbout .size () > BATCH_SIZE ) {
1600
+ while (nodeBatch.NodesToAskAbout .size () > OffloadMergeBatchSize ) {
1595
1601
TNodeBatch newBatch;
1596
- size_t splitSize = std::min (BATCH_SIZE , nodeBatch.NodesToAskAbout .size () / 2 );
1602
+ size_t splitSize = std::min (OffloadMergeBatchSize , nodeBatch.NodesToAskAbout .size () / 2 );
1597
1603
newBatch.NodesToAskAbout .reserve (splitSize);
1598
1604
for (size_t i = 0 ; i < splitSize; ++i) {
1599
1605
newBatch.NodesToAskAbout .push_back (nodeBatch.NodesToAskAbout .back ());
@@ -2105,6 +2111,9 @@ class TJsonNodes : public TViewerPipeClient {
2105
2111
FieldsRequired.set (+ENodeFields::SystemState);
2106
2112
}
2107
2113
std::vector<TNodeBatch> batches = BatchNodes (NodeView);
2114
+ if (DumpOriginalNodeBatches) {
2115
+ OriginalNodeBatches = batches;
2116
+ }
2108
2117
if (FilterPeerRole == EPeerRole::Static || FilterPeerRole == EPeerRole::Other) {
2109
2118
for (TNodeBatch& batch : batches) {
2110
2119
batch.FieldsRequested .set (+ENodeFields::Peers);
@@ -3101,6 +3110,16 @@ class TJsonNodes : public TViewerPipeClient {
3101
3110
AddEvent (" ReplyAndPassAway" );
3102
3111
ApplyEverything ();
3103
3112
NKikimrViewer::TNodesInfo json;
3113
+ for (const auto & batch : OriginalNodeBatches) {
3114
+ auto * jsonBatch = json.AddOriginalNodeBatches ();
3115
+ for (const auto & node : batch.NodesToAskFor ) {
3116
+ jsonBatch->AddNodesToAskFor (node->GetNodeId ());
3117
+ }
3118
+ for (const auto & node : batch.NodesToAskAbout ) {
3119
+ jsonBatch->AddNodesToAskAbout (node->GetNodeId ());
3120
+ }
3121
+ jsonBatch->SetHasStaticNodes (batch.HasStaticNodes );
3122
+ }
3104
3123
json.SetVersion (Viewer->GetCapabilityVersion (" /viewer/nodes" ));
3105
3124
json.SetFieldsAvailable (FieldsAvailable.to_string ());
3106
3125
json.SetFieldsRequired (FieldsRequired.to_string ());
0 commit comments