perf(indexers): offload sync embed_text to thread across background workers

Connector kb_sync_services (gmail, onedrive, google_calendar, jira),
streaming indexers (discord, luma, teams) and the file-processor save
path all called embed_text inside async coroutines, blocking the
background worker's event loop for the duration of the embed. Wrap each
call site in asyncio.to_thread so concurrent indexing tasks stop
serialising on the embed.
This commit is contained in:
CREDO23 2026-05-20 10:09:38 +02:00
parent a8de98895a
commit 1791241c0c
8 changed files with 34 additions and 11 deletions

View file

@ -1,3 +1,4 @@
import asyncio
import logging
from datetime import datetime
@ -100,7 +101,9 @@ class GmailKBSyncService:
else:
logger.warning("No LLM configured -- using fallback summary")
summary_content = f"Gmail Message: {subject}\n\n{indexable_content}"
summary_embedding = embed_text(summary_content)
summary_embedding = await asyncio.to_thread(
embed_text, summary_content
)
chunks = await create_document_chunks(indexable_content)
now_str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")