-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add IThreadPoolWorkItem
support to ThreadPoolDispatcher
#5943
Add IThreadPoolWorkItem
support to ThreadPoolDispatcher
#5943
Conversation
#else | ||
// use native .NET 6 APIs here to reduce allocations | ||
// preferLocal to help reduce context switching | ||
ThreadPool.UnsafeQueueUserWorkItem(run, true); |
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.
Major change here - leverages new overload to the ThreadPool.UnsafeQueueUserWorkItem
method added in .NET Core 3.0: https://docs.microsoft.com/en-us/dotnet/api/system.threading.threadpool.unsafequeueuserworkitem?view=net-6.0
So Akka.Remote can't take advantage of this without:
That being said, I'm going to benchmark it. |
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.
LGTM
Significantly improves the message processing throughput of actors by reducing delegate invocations and taking advantage of thread locality.
Edit: and by thread locality, I mean significantly reduced context-switching for actors.
Changes
Added
IThreadPoolWorkItem
to allIRunnable
implementations.Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):
Latest
dev
BenchmarksUsing the in-memory PingPong benchmark on .NET 6
This PR's Benchmarks