Change Timer implementation on Unixes to use only one scheduling thread#7071
Conversation
|
RE this from #7066:
The max number of scheduled timers is the proc count, so the lock should be held for a very short time and it doesn't scale worse beyond that. CoreCLR queues an APC to the timer thread to insert a new timer, which is nice in that it doesn't need a lock, but I'm not aware of a way to do that in .NET and it would still involve some kind of synchronization in |
|
Made a change to move the queuing out of the lock, as that's probably the most expensive part |
|
I became convinced that you are right about it and agree with your reasoning. I always hesitate to add contention on yet another lock, but in this particular case it's unlikely to cause an issue since the number of processor cores is usually quite low. I think there's room for improvement of how the code is structured given how the current three implementations (CoreCLR, CoreRT/Unix, CoreRT/Windows) turned out, but it's nowhere near anything I would even consider a priority. If I identify some small areas that need to be improved I will be happy to address them specifically. |
It is possible to get rid of the lock by using lock-free list (eg. the basic idea from Looking at the code again I came to the conclusion that With your implementation it will start creating One possible fix is to get rid of |
|
Nice catch and good ideas, will fix |
|
LGTM... It actually resolves issue with the |
|
@dotnet-bot test OSX10.12 Debug and CoreCLR tests |
|
Jenkins is shut down for those configs. I'll close and reopen this to retest with Azure DevOps. |
|
@stephentoub could you help to land this change? |
|
@filipnavara Thanks for signing off on this |
CC @filipnavara