Abraxas-365 / Abraxas-365/langchain-rust
async operations are not really async
- Linguagem predominante
- Rust
- Estrelas
- 1.3k
- Forks
- 177
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- rust
- Domínio
- backend, performance
- Tipo de issue
- Refatoração
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 30/100