Abraxas-365 / Abraxas-365/langchain-rust
async operations are not really async
- Lingua principale
- Rust
- Stelle
- 1.3k
- Fork
- 177
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.