From 5b0e0a075d8a7992007126b3df599137213e3d39 Mon Sep 17 00:00:00 2001 From: stanbot8 Date: Thu, 5 Mar 2026 10:20:15 +0000 Subject: [PATCH] Skip AddAgentsToRm when no contexts have pending agents AddAgentsToRm runs every step in both SetupIterationAll and TearDownIterationAll. On steps where no agents were created, the function still allocated NUMA vectors, called ResizeAgentUidMap, GrowAgentContainer(0), and entered an OMP parallel region. Add an early-out scan that checks all execution contexts for empty new_agents_ and returns immediately when nothing to commit. --- src/core/execution_context/in_place_exec_ctxt.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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());