Skip to content

Commit 106024e

Browse files
committed
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.
1 parent b8aa228 commit 106024e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/core/execution_context/in_place_exec_ctxt.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,19 @@ void InPlaceExecutionContext::RemoveAgent(const AgentUid& uid) {
318318

319319
void InPlaceExecutionContext::AddAgentsToRm(
320320
const std::vector<ExecutionContext*>& all_exec_ctxts) {
321+
// Skip entirely when no execution context has pending agents
322+
bool any_new = false;
323+
for (int i = 0; i < tinfo_->GetMaxThreads(); ++i) {
324+
auto* ctxt = bdm_static_cast<InPlaceExecutionContext*>(all_exec_ctxts[i]);
325+
if (!ctxt->new_agents_.empty()) {
326+
any_new = true;
327+
break;
328+
}
329+
}
330+
if (!any_new) {
331+
return;
332+
}
333+
321334
// group execution contexts by numa domain
322335
std::vector<uint64_t> new_agent_per_numa(tinfo_->GetNumaNodes());
323336
std::vector<uint64_t> thread_offsets(tinfo_->GetMaxThreads());

0 commit comments

Comments
 (0)