Abraxas-365 / Abraxas-365/langchain-rust
async operations are not really async
- 主要語言
- Rust
- 星號
- 1.3k
- 分支
- 177
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Hi, I've been working on a langchain variant in Rust myself, and I am reading this project to compare notes.
I can offer a tip, something I've bumped into in the past: when running CPU bound operations (loading text from PDF, splitting text, embedding, and more), you need to offload to one of the two:
1. Tokio's builtin async pool with an async task
2. Create your own dedicated pool for specific resources (a pool for embedders, a pool for splitters, etc), and offload to that dedicated pool (still using Tokio, of course)
For one-time loading during boot process of the app or similar workflow I recommend (1),
For multi-request processing, such as initializing a full-blown chain and then putting it on a webservice for serving multiple inference requests (with the same chain), I recommend (2).
It is a non-trivial refactor as you might discover some pieces of code are not `Sync` or `Send` and you'll have to drill down to make them such.
However, there's no getting around this kind of refactor, as currently CPU bound operations will completely block Tokio's async operations and make using Tokio pointless.
貢獻指南
研究方向
The issue points to CPU-bound operations like PDF loading, text splitting, and embedding that block Tokio's async runtime. Look for these operations in the codebase, likely in modules handling document loaders, text splitters, and embedders. Investigate whether the relevant structs and functions are Send and Sync, and consider using tokio::task::spawn_blocking or dedicated thread pools. Testing changes will require benchmarking async throughput under load.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- rust
- 領域
- backend, performance
- Issue 類型
- 重構
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 30/100