diff --git a/src/core/execution_context/in_place_exec_ctxt.cc b/src/core/execution_context/in_place_exec_ctxt.cc index 0032961ff..adf66cbcf 100644 --- a/src/core/execution_context/in_place_exec_ctxt.cc +++ b/src/core/execution_context/in_place_exec_ctxt.cc @@ -318,6 +318,19 @@ void InPlaceExecutionContext::RemoveAgent(const AgentUid& uid) { void InPlaceExecutionContext::AddAgentsToRm( const std::vector& all_exec_ctxts) { + // Skip entirely when no execution context has pending agents + bool any_new = false; + for (int i = 0; i < tinfo_->GetMaxThreads(); ++i) { + auto* ctxt = bdm_static_cast(all_exec_ctxts[i]); + if (!ctxt->new_agents_.empty()) { + any_new = true; + break; + } + } + if (!any_new) { + return; + } + // group execution contexts by numa domain std::vector new_agent_per_numa(tinfo_->GetNumaNodes()); std::vector thread_offsets(tinfo_->GetMaxThreads());