Skip to content
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

Ensure thread pool has at least 2 threads when profiling is enabled #5735

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mediapipe/framework/calculator_graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ absl::Status CalculatorGraph::InitializeDefaultExecutor(
std::max({validated_graph_->Config().node().size(),
validated_graph_->Config().packet_generator().size(), 1}));
}
#ifdef MEDIAPIPE_PROFILER_AVAILABLE
// Ensure that the thread pool has at least 2 threads when profiling is enabled.
// This is necessary because the PROFILING function relies on the thread pool
// for its operations, and having only 1 thread may lead to contention,
// preventing the Calculator's Process function from being scheduled.
num_threads = std::max(num_threads, 2);
#endif
MP_RETURN_IF_ERROR(
CreateDefaultThreadPool(default_executor_options, num_threads));
VLOG(1) << absl::StrCat("Using default executor with num_threads: ",
Expand Down