Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changes/9718.enhance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deduplicate container IDs in agent stat collection to avoid redundant processing
12 changes: 6 additions & 6 deletions src/ai/backend/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,25 +1388,25 @@ async def collect_node_stat(self, resource_scaling_factors: Mapping[SlotName, De
async def collect_container_stat(self, interval: float) -> None:
if self.local_config.debug.log_stats:
log.debug("collecting container statistics")
container_ids: list[ContainerId] = []
container_ids: set[ContainerId] = set()
for kernel_obj in [*self.kernel_registry.values()]:
if not kernel_obj.stats_enabled or kernel_obj.container_id is None:
continue
container_ids.append(ContainerId(kernel_obj.container_id))
container_ids.add(ContainerId(kernel_obj.container_id))
async with asyncio.timeout(STAT_COLLECTION_TIMEOUT):
await self.stat_ctx.collect_container_stat(container_ids)
await self.stat_ctx.collect_container_stat(list(container_ids))

@_observe_stat_task(stat_scope=StatScope.PROCESS)
async def collect_process_stat(self, interval: float) -> None:
if self.local_config.debug.log_stats:
log.debug("collecting process statistics in container")
container_ids = []
container_ids: set[ContainerId] = set()
for kernel_obj in [*self.kernel_registry.values()]:
if not kernel_obj.stats_enabled or kernel_obj.container_id is None:
continue
container_ids.append(ContainerId(kernel_obj.container_id))
container_ids.add(ContainerId(kernel_obj.container_id))
async with asyncio.timeout(STAT_COLLECTION_TIMEOUT):
await self.stat_ctx.collect_per_container_process_stat(container_ids)
await self.stat_ctx.collect_per_container_process_stat(list(container_ids))

def _get_public_host(self) -> str:
agent_config = self.local_config.agent
Expand Down
Loading