MCPcopy Create free account
hub / github.com/catboost/catboost / StopSlaves

Method StopSlaves

library/cpp/par/par_remote.cpp:259–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257 }
258
259 void TRemoteQueryProcessor::StopSlaves() {
260 TIntrusivePtr<TMetaRequester> mr(new TMetaRequester(this));
261 DEBUG_LOG << "Stopping slaves" << Endl;
262 fflush(nullptr);
263 int searcherCount = GetSlaveCount();
264 TVector<bool> chkStopRes;
265 chkStopRes.resize(searcherCount, false);
266 for (bool canStop = false; !canStop;) {
267 for (int i = 0; i < searcherCount; ++i) {
268 if (!chkStopRes[i]) {
269 mr->AddQuery(i, "check_stop", nullptr);
270 }
271 }
272 TVector<TVector<char>> res;
273 mr->GetResults(&res);
274 canStop = true;
275 for (int i = 0; i < res.ysize(); ++i) {
276 if (chkStopRes[i]) {
277 continue;
278 }
279 bool resVal = (res[i][0] != 0);
280 chkStopRes[i] = resVal;
281 canStop &= resVal;
282 }
283 }
284 DEBUG_LOG << "Gathering debug stats from slaves" << Endl;
285 for (int i = 0; i < searcherCount; ++i) {
286 mr->AddQuery(i, "gather_stats", nullptr);
287 }
288 auto& masterTimings = Singleton<TParHostStats>()->ParTimings;
289 TVector<TVector<char>> res;
290 mr->GetResults(&res);
291 Y_ABORT_UNLESS(
292 res.ysize() == searcherCount,
293 "res.ysize()=%d, searcherCount=%d",
294 res.ysize(), searcherCount);
295 for (int i = 0; i < searcherCount; ++i) {
296 TParHostStats tmpStats;
297 SerializeFromMem(&res.at(i), tmpStats);
298 for (size_t j = 0; j < static_cast<size_t>(ETimingTag::TimingsCount); ++j) {
299 *masterTimings.Timings[j] += *tmpStats.ParTimings.Timings[j];
300 }
301 }
302 DEBUG_LOG << "Cumulative timings: " << Endl;
303 for (size_t i = 0; i < static_cast<size_t>(ETimingTag::TimingsCount); ++i) {
304 Cout << static_cast<ETimingTag>(i) << ": " << static_cast<double>(*masterTimings.Timings[i]) << Endl;
305 }
306 for (int i = 0; i < searcherCount; ++i) {
307 mr->AddQuery(i, "stop", nullptr);
308 }
309 mr->GetResults(nullptr);
310 }
311
312 void TRemoteQueryProcessor::IncLastCount(int compId) {
313 Y_ASSERT(compId >= 0 && compId < LastCounts.ysize());

Callers 1

StopMethod · 0.80

Calls 6

SerializeFromMemFunction · 0.85
GetResultsMethod · 0.80
resizeMethod · 0.45
AddQueryMethod · 0.45
ysizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected