Concurrent batched vector embeddings#110
Conversation
- Refactored `Weaver._execute_batched_vector` to offload synchronous embedding generation (`self.embed_fn`) and vector store I/O (`store.add`, `store.delete`) to an executor thread pool (`loop.run_in_executor`). - Replaced sequential processing in `flush_add_batch` with `asyncio.gather(*tasks, return_exceptions=True)` to execute all vector operations for a given batch concurrently. - Re-architected error handling around metadata extraction and embedding execution to ensure robust failures are localized to single operations instead of failing the entire batch or skipping subsequently enqueued `DELETE` operations.
|
👋 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:
Optimized
Weaver._execute_batched_vectorto compute batch embeddings concurrently and offloaded synchronousvector_storeoperations (add,delete) to the thread pool (run_in_executor) to avoid blocking the event loop.🎯 Why:
Previously,
flush_add_batchgenerated embeddings and executed additions/deletions completely synchronously inside theasync deffunction. This created a performance bottleneck by forcing the single-threaded event loop to wait on blocking operations (often I/O bound ifembed_fnmakes HTTP requests, or CPU bound if done locally).📊 Impact:
🔬 Measurement:
A new script
verify_weaver_batch.pywas introduced at the root to test the execution latency programmatically with mocked delays. You can run it via:PR created automatically by Jules for task 9188823495244099766 started by @ishaanxgupta