justinstenning / SharedMemory

C# shared memory classes for sharing data between processes (Array, Buffer and Circular Buffer)
https://www.nuget.org/packages/SharedMemory
Other
566 stars 118 forks source link

Performance Optimization #54

Closed Christian-Schl closed 3 years ago

Christian-Schl commented 3 years ago

In an multithreaded environment which high usage of the Task Api / ThreadPool the "await Task.Run(()" cause slow message process times because of context switching and waiting for free threads.

To change this i have replace the logic and now the TaskCompletionSource is used.

Also i have remove TargetFramework net35 because it cause some problems on my maschine (missing 3.5 SDK)

Please check pull request

Best regrads Christian

Christian-Schl commented 3 years ago

Performance results

I have use the RPC_LoadTest_5k_Small_Multi_Thread as an base line. Because the performance of async await depends on the sie of the ThreadPool if have test two configurations.

Small Threadpool: 15 worker threads Large Threadpool: 100 worker threads

without optimization small threadpool: 10.5 sec large threadpool: 1.5 sec

with optimization small threadpool 700 ms large threadpool 700 ms