Open NickCraver opened 2 years ago
Slimming down the above table to compare what we are asking here: MutexSlim
vs. SemaphoreSlim
:
Method | Runtime | Mean | Error | StdDev | Allocated |
---|---|---|---|---|---|
SemaphoreSlim_Sync | .NET 6.0 | 18.246 ns | 0.2540 ns | 0.2375 ns | - |
MutexSlim_Sync | .NET 6.0 | 22.292 ns | 0.1948 ns | 0.1627 ns | - |
SemaphoreSlim_Sync | .NET 4.7.2 | 65.291 ns | 0.5218 ns | 0.4357 ns | - |
MutexSlim_Sync | .NET 4.7.2 | 43.145 ns | 0.3944 ns | 0.3689 ns | - |
SemaphoreSlim_Async | .NET 6.0 | 20.920 ns | 0.2461 ns | 0.2302 ns | - |
MutexSlim_Async | .NET 6.0 | 42.810 ns | 0.4583 ns | 0.4287 ns | - |
SemaphoreSlim_Async | .NET 4.7.2 | 57.513 ns | 0.5600 ns | 0.5238 ns | - |
MutexSlim_Async | .NET 4.7.2 | 76.444 ns | 0.3811 ns | 0.3379 ns | - |
SemaphoreSlim_Async_HotPath | .NET 6.0 | 15.182 ns | 0.1708 ns | 0.1598 ns | - |
MutexSlim_Async_HotPath | .NET 6.0 | 29.913 ns | 0.5884 ns | 0.6776 ns | - |
SemaphoreSlim_Async_HotPath | .NET 4.7.2 | 50.912 ns | 0.8782 ns | 0.8215 ns | - |
MutexSlim_Async_HotPath | .NET 4.7.2 | 55.409 ns | 0.7513 ns | 0.6660 ns | - |
SemaphoreSlim_ConcurrentAsync | .NET 6.0 | 2,084.316 ns | 4.5909 ns | 4.0698 ns | 547 B |
MutexSlim_ConcurrentAsync | .NET 6.0 | 2,120.714 ns | 28.5866 ns | 26.7399 ns | 125 B |
SemaphoreSlim_ConcurrentAsync | .NET 4.7.2 | 3,812.444 ns | 42.4014 ns | 37.5877 ns | 1,449 B |
MutexSlim_ConcurrentAsync | .NET 4.7.2 | 2,883.994 ns | 46.5535 ns | 41.2685 ns | 284 B |
Issue for tracking this discussion (so I can also put benchmarks somewhere).
Getting benchmarks running again for a discussion around going back to SemaphoreSlim now that the async issue has been fixed. Current benchmark run shows positive results there:
cc @mgravell ^ I can take a poke at what a swap looks like this week just wanted to post numbers up!