⚡ Bolt: [performance improvement] Concurrent embedding generation in Weaver#87
⚡ Bolt: [performance improvement] Concurrent embedding generation in Weaver#87ishaanxgupta wants to merge 1 commit intomainfrom
Conversation
Replaced sequential iteration over vector ADD operations with concurrent execution using `asyncio.gather` and `asyncio.get_running_loop().run_in_executor` in the Weaver pipeline to significantly reduce latency caused by sequential synchronous API calls.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What:
Refactored
flush_add_batchinsrc/pipelines/weaver.pyto concurrently generate embeddings for all validADDoperations before inserting them into the vector store.🎯 Why:
The
embed_fnmakes a synchronous network request to an embedding service. When processing a batch of operations (e.g., from an ingestion pipeline extraction), calling this function sequentially inside anasyncloop blocks the event loop and multiplies network latency by the number of operations in the batch.📊 Impact:
Reduces the time complexity of embedding generation for a batch of
Nadditions fromO(N)round-trips to ~O(1)(dependent on thread pool size), significantly lowering the latency of the Weaver pipeline for large inputs.🔬 Measurement:
By mocking
embed_fnwith a sleep, execution ofNitems drops fromNseconds to1second. The event loop is no longer blocked.PR created automatically by Jules for task 4337648397894169834 started by @ishaanxgupta