FEATURE REQUEST:Fix EmbeddingService blocking the event loop
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Bắt đầu trong backend/app/services/embedding_service/service.py, tập trung vào get_embedding và get_embeddings cùng các lệnh gọi model.encode đồng bộ của chúng. Xem xét các consumer trong app/services/github/user/profiling.py, app/services/github/issue_processor.py và app/agents/devrel/github/tools/contributor_recommendation.py; được xem là hoàn tất khi API async công khai không thay đổi và một request async khác vẫn phản hồi trong khi embeddings đang được tạo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem?
- Yes, it is related to a problem
Describe the feature you'd like
🌟Feature Description
Offload blocking embedding work from the async event loop so that EmbeddingService does not block other concurrent requests. The service should run CPU/GPU-bound model.encode() calls in a thread pool (e.g. via asyncio.to_thread()) while keeping the public API async.
🔍 Problem Statement
EmbeddingService exposes async methods (get_embedding, get_embeddings, summarize_user_profile, search_similar_profiles) but internally calls synchronous SentenceTransformer code:
self.model.encode(...)inget_embeddingandget_embeddingsis blocking. It runs on CPU/GPU and does not yield to the event loop.- While one request is generating embeddings, the entire process is blocked: other HTTP requests, agent tools, and background tasks stall until the encode finishes.
- The LLM call in
summarize_user_profilecorrectly usesawait self.llm.ainvoke(...)and is non-blocking; only the embedding step blocks.
This hurts latency and concurrency wherever the service is used (e.g. issue_processor.py, contributor_recommendation.py, user profiling).
🎯 Expected Outcome
- Event loop stays responsive during embedding generation: other async work (API handlers, other embeddings, LLM calls) can run while
model.encode()runs in a worker thread. - No change to the public API: callers keep using
await embedding_service.get_embedding(...)andawait embedding_service.get_embeddings(...). - Implementation approach: add a synchronous helper that performs
model.encode()and tensor-to-list conversion; call it fromget_embeddingandget_embeddingsviaasyncio.to_thread()(orloop.run_in_executor()with aThreadPoolExecutor). - Optional: run model lazy-load in a thread at first use to avoid blocking on first request.
📷 Screenshots and Design Ideas
Before: One long embedding request blocks the event loop → other requests wait.
After: Embedding runs in a thread pool → event loop continues handling other requests; embedding call still awaited by the original request.
No UI changes; this is a backend concurrency fix.
📋 Additional Context
- File to change:
backend/app/services/embedding_service/service.py - Consumers:
app/services/github/user/profiling.py,app/services/github/issue_processor.py,app/agents/devrel/github/tools/contributor_recommendation.py - Suggested steps:
- Add
import asyncio. - Add a sync helper method (e.g.
_encode(texts)) that callsself.model.encode(...)and returns list(s) of floats. - In
get_embedding: replace directmodel.encodewithawait asyncio.to_thread(self._encode, [text]), then return the single embedding list. - In
get_embeddings: replace directmodel.encodewithawait asyncio.to_thread(self._encode, texts)and return the list of lists.
- Add
- Verification: While one request is generating embeddings, trigger another (e.g. health check or simple async endpoint); the second should respond without waiting for the first.
Record
- I agree to follow this project's Code of Conduct
- I want to work on implementing this feature
- Ngôn ngữ chính
- Python
- Star
- 103
- Fork
- 143
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AOSSIE-Org/Devr.AI
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
AOSSIE-Org/Devr.AI#315 · 1 bình luận ·
-
Bump Weaviate image to 1.39.13 (Go 1.26.10 / CVE-2026-111943)Có thể đã có người làm @dudanogueira đã nhận 38 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
AOSSIE-Org/Devr.AI#309 · 1 bình luận ·
-
DOCS UPDATE: Incorrect Flask command path in backend installation guideCó thể đã có người làm @Ashwin-Pillai-22 đã nhận 321 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
AOSSIE-Org/Devr.AI#229 · 3 bình luận ·
-
BUG:Devr.AI Agent loses user_profile for returning users and fails to persist conversation summaries & cumulative interaction countsCó thể đã có người làm @shubhumre777 đã nhận 34 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
AOSSIE-Org/Devr.AI#311 · 2 bình luận ·
-
BUG: Local pytest suite fails to collect due to deprecated imports and mock schemasCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
AOSSIE-Org/Devr.AI#307 · 1 bình luận ·
Tất cả issue của AOSSIE-Org/Devr.AI
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pimutils/vdirsyncer#1242 ·
-
priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
QuantConnect/lean-cli#792 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
open-webui/open-webui#35360 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100