-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
Sylvie: Actix uses multiple single-thread tokio runtimes instead of a single multi-threaded one by design. Specifically to allow Me: Got it. Makes sense. Is it possible to emulate this behaviour with hyper? Sylvie: Possible, yes; desirable, hard to tell. So this is a pretty complex task, depending on the usecase you might want to consider making your types threadsafe instead. Again depending on the exact usecase you could also just go for a single single-threaded runtime - you'd still be able to use your !Send types and .await points would still allow concurrency, but blocking code will block the entire service. Me: My goal was to reduce depencies: This PR brings down total dependencies from 328 to 275. Looks like not worth it for now. Thanks for the help 🙏 Sylvie: Yeah, refactoring other major parts of a codebase or potentially having to re-invent the wheel doesn't sound worth it for shaving off like 50 dependencies. Glad I could help! Why exactly did you want to reduce dependencies btw? If it's to improve compile times, I can also recommend completely turning off the macros feature on actix and doing everything with plain function calls; that helped a lot for me. (But then again I didn't have many handlers or a lot of logic in them to begin with, so that made it easy to get rid of the few macros I was using). |
Ilyvion: Actix promises single-thread execution per request to the best of my knowledge. I.e. it is multi-threaded, but any one request will start, run and complete on the same thread. This is how it can use things like Rc in per-request situations internally, e.g. The documentation for Actix says that
Source: https://docs.rs/actix-rt/latest/actix_rt/ So you'd have to do the same thing yourself, spin up a bunch of runtimes and then manage the handing over of requests to whatever runtime is free to accept a task. I think it's mostly the "arbiter" doing this work, although fair warning: I'm not intimately familiar with Actix' inner workings. https://github.com/actix/actix-net/blob/master/actix-rt/src/arbiter.rs |
@amitu : The code is compiling for me locally. Now that is rather odd!!! |
@gabhijit: https://github.com/FifthTry/fpm/pull/532/files#diff-7da576f5c8e7ffe1f4d334844eec78ed27e092a9bacdad959a54468904d870b2R349-R352 |
This PR brings down total dependencies from 328 to 275. But fails to compile: