MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RecomputePoolStatsLocked

Method RecomputePoolStatsLocked

tensorflow/core/framework/run_handler.cc:659–713  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657};
658
659void RunHandlerPool::Impl::RecomputePoolStatsLocked() {
660 int num_active_requests = sorted_active_handlers_.size();
661 if (num_active_requests == 0) return;
662 Eigen::MaxSizeVector<ThreadWorkSource*> thread_work_sources(
663 num_active_requests);
664
665 thread_work_sources.resize(num_active_requests);
666 for (int i = 0; i < num_active_requests; ++i) {
667 thread_work_sources[i] = sorted_active_handlers_[i]->tws();
668 thread_work_sources[i]->SetRank(i);
669 }
670
671 int num_threads = run_handler_thread_pool()->NumThreads();
672 int num_blocking_threads = run_handler_thread_pool()->NumBlockingThreads();
673 int num_non_blocking_threads = num_threads - num_blocking_threads;
674
675 std::vector<int> request_idx_list = ChooseRequestsWithExponentialDistribution(
676 num_active_requests, num_blocking_threads);
677 for (int i = 0; i < num_blocking_threads; ++i) {
678 VLOG(2) << "Set work for tid=" << i
679 << " with start_request_idx=" << request_idx_list[i];
680 run_handler_thread_pool()->SetThreadWorkSources(i, request_idx_list[i],
681 thread_work_sources);
682 }
683
684 request_idx_list = ChooseRequestsWithExponentialDistribution(
685 num_active_requests, num_non_blocking_threads);
686 for (int i = 0; i < num_non_blocking_threads; ++i) {
687 VLOG(2) << "Set work for tid=" << (i + num_blocking_threads)
688 << " with start_request_idx=" << request_idx_list[i];
689 run_handler_thread_pool()->SetThreadWorkSources(
690 i + num_blocking_threads, request_idx_list[i], thread_work_sources);
691 }
692
693 if (iterations_++ % 50000 == 10 && VLOG_IS_ON(1)) {
694 VLOG(1) << "Printing time histogram: " << time_hist_.ToString();
695 VLOG(1) << "Active session runs: " << num_active_requests;
696 uint64 now = tensorflow::Env::Default()->NowMicros();
697 string times_str = "";
698 string ids_str = "";
699 for (int i = 0; i < num_active_requests; ++i) {
700 if (i > 0) {
701 times_str += " ";
702 ids_str += " ";
703 }
704
705 times_str += strings::StrCat(
706 (now - sorted_active_handlers_[i]->start_time_us()) / 1000.0, " ms.");
707 ids_str +=
708 strings::StrCat(sorted_active_handlers_[i]->tws()->GetTracemeId());
709 }
710 VLOG(1) << "Elapsed times are: " << times_str;
711 VLOG(1) << "Step ids are: " << ids_str;
712 }
713}
714
715// It is important to return a value such as:
716// CurrentThreadId() in [0, NumThreads)

Callers

nothing calls this directly

Calls 14

DefaultFunction · 0.85
twsMethod · 0.80
SetRankMethod · 0.80
NumBlockingThreadsMethod · 0.80
SetThreadWorkSourcesMethod · 0.80
start_time_usMethod · 0.80
GetTracemeIdMethod · 0.80
StrCatFunction · 0.50
sizeMethod · 0.45
resizeMethod · 0.45
NumThreadsMethod · 0.45

Tested by

no test coverage detected