-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set editoast tokio flavor multi-thread #7924
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like an incredibly simple yet perfect solution
This does not fix the usage of |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## dev #7924 +/- ##
============================================
- Coverage 28.48% 28.45% -0.04%
Complexity 2059 2059
============================================
Files 1254 1256 +2
Lines 154469 154592 +123
Branches 3047 3049 +2
============================================
- Hits 44007 43993 -14
- Misses 108647 108782 +135
- Partials 1815 1817 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Use tokio multi thread scheduler instead of current thread
e9bb499
to
30d3cbc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Digging a bit into actix-web
, it seems to basically launch as many actix worker as there is CPU available by default. An actix worker is basically an OS thread with a mono-thread tokio
runtime in it. Here is how it works.
- We set up the number of actix worker in
editoast
- This number of worker is stored into
threads
of theServerBuilder
into our instance ofHTTPServer
- This
threads
number is used to instantiate as manyServerWorker
- In the
ServerWorker::start
, the handle on the currenttokio::Runtime
is gathered - Always in
ServerWorker::start
, a new OS thread is spawned (remember,ServerWorker::start
is called as many times as there is workers) - Finally, inside this new OS thread, a new mono-threaded
tokio
runtime is launched
Note that a lot is happening in ServerWorker::start
which I'm not entirely sure the impact. But basically, it probably doesn't matter if our fn main
is multi-threaded or not since actix is basically running a mono-threaded tokio
runtime in independent OS threads from what I understand.
That said, I believe that defaulting to a multi-threaded tokio
runtime is good anyway, even if it might not help us in what we're looking for.
My bad, I thought it would. |
Tokio doc: https://docs.rs/tokio/latest/tokio/attr.main.html#multi-threaded-runtime
Note
When printing the flavor in the main we have
MultiThread
instead ofCurrentThread
.However we still observe
CurrentThread
when printing inside an endpoint.