Redesign CLI executor to avoid spin looping when idle#4994
Redesign CLI executor to avoid spin looping when idle#4994jedel1043 wants to merge 8 commits intoboa-dev:mainfrom
Conversation
Test262 conformance changes
Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4994 +/- ##
===========================================
+ Coverage 47.24% 59.50% +12.25%
===========================================
Files 476 580 +104
Lines 46892 63301 +16409
===========================================
+ Hits 22154 37666 +15512
- Misses 24738 25635 +897 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Test262 conformance changes
Tested main commit: |
| #[cfg(debug_assertions)] | ||
| { | ||
| let callback = self.0.take(); | ||
| assert!( | ||
| callback.is_some(), | ||
| "setting a callback on an already used cancellation token" | ||
| ); | ||
| } |
There was a problem hiding this comment.
Isn't this just:
| #[cfg(debug_assertions)] | |
| { | |
| let callback = self.0.take(); | |
| assert!( | |
| callback.is_some(), | |
| "setting a callback on an already used cancellation token" | |
| ); | |
| } | |
| debug_assert!(self.0.take().is_none(), "setting a callback on an already used cancellation token"); |
Also, I think the logic is wrong, you want to make sure it's None before setting it.
There was a problem hiding this comment.
Nah, it needs to check if it is Some, otherwise the token has already been used and the Cell has a None on its place
The design of our current event loop on the CLI has a couple of warts; one of them being that if there are any async jobs or timeout jobs but not any other type of job on the queue, it will start spin looping, consuming a lot of CPU resources.
This PR completely redesigns our event loop to use
smoland cooperative async tasks to push the jobs forward, which avoids spin looping by delegating pauses and timeouts tosmol(effectively delegating those to the OS, and OS sleeping = 0% CPU usage). This redesign also modularizes the way jobs are ran; instead of having a big loop that goes through all of the job queues at once, it extracts the running logic of each job queue into independent async tasks