-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Semaphore performance issue #113411
Comments
Tagging subscribers to this area: @mangod9 |
You can try |
Other runtimes are able to get better performance so certainly something we can investigate. |
Is using ReaderWriter lock necessary here? Is issue scoped to Semaphore only or a combination of Semaphore and ReaderWriter lock? When you say other runtimes, which ones? Can they optimize out an empty acquire-release seeing that DoWork actually does nothing? |
Dont believe RWLock makes a difference.
Fair point, it's a possibility, but unlikely that a compiler would be able to make the determination and completely remove the acquire/release? But worth looking into. |
Using a semaphore that wraps the OS primitive? Or using their built-in semaphore type? Or using a hand-rolled semaphore? |
|
Description
There's a performance issue regarding Semaphore in scenarios where threads request and release the semaphore with no work in between as shown in the snippet below. The rate of transactions is up to 3-4 times lower compared to other runtimes.
This scenario was tested with .NET 9, arch x64 for both Windows and Linux. Machines had 16 vcpus and the test was ran using 8 threads during 30 seconds.
The transactions per second rate on Windows is ~320K whereas on Linux the rate is ~130K. Other runtimes can achieve around ~500K+ on both platforms.
Native AOT achieved similar results to the non Native AOT versions.
The text was updated successfully, but these errors were encountered: