[FrontEnd][Perf] merge_async_iterators fast-path for single-prompt requests (#15150)

Signed-off-by: Nick Hill <nhill@redhat.com>
This commit is contained in:
Nick Hill 2025-03-19 14:04:41 -07:00 committed by GitHub
parent b0e96aaebb
commit 22d33baca2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -411,6 +411,11 @@ async def merge_async_iterators(
When it yields, it yields a tuple (i, item) where i is the index of the
iterator that yields the item.
"""
if len(iterators) == 1:
# Fast-path single iterator case.
async for item in iterators[0]:
yield 0, item
return
loop = asyncio.get_running_loop()