Attempt to optimize LocalExecutor #144
Draft
+851
−258
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes
LocalExecutor
it's own separate implementation instead of wrapping an Executor, forking it's ownState
type utilizing unsynchronized!Send
types where possible:Arc
->Rc
,Mutex
->RefCell
,AtomicPtr
->Cell<*mut T>
,ConcurrentQueue
->VecDeque
. This implementation also removes any extra operations that assumes there are other concurrent Runners/Tickers (i.e. local queues, extra notifications).For testing, I've duplicated most of the single-threaded compatible executor tests to ensure there's equivalent coverage on the new independent
LocalExecutor
.I've also made an attempt to write this with
UnsafeCell
instead ofRefCell
, but this litters a huge amount ofunsafe
that might be too much for this crate. The gains here might not be worth it.I previously wrote some additional benchmarks but lost the changes to a stray
git reset --hard
when benchmarking.The gains here are substantial. Here are the results:
TODO: Recreate these benchmarks.