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

Set spin count to 1 in ManualResetEventSlim #1830

Merged
merged 1 commit into from Jan 25, 2019

Conversation

2 participants
@shaan1337
Copy link
Member

shaan1337 commented Jan 17, 2019

Symptoms:

  • High CPU usage when idle (particularly for StorageChaser,~40% CPU when idle)

This PR fixes performance issues seen after introducing this commit which was hoping that the issues seen earlier with ManualResetEventSlim on mono were fixed in mono 5.16.

The same high CPU usage symptoms were seen earlier in this commit and the workaround was to use AutoResetEvent:
95be10a

After experimentation, setting the spinCount to 1 drops the CPU usage to 0-5% and write speeds increase by approximately 50% (atleast on my laptop).

It seems that default spin count of 10 used by mono was too high, causing excess spinning (this was manually verified by setting the spin count to 10):
https://github.com/mono/mono/blob/master/mcs/class/referencesource/mscorlib/system/threading/ManualResetEventSlim.cs#L57

Set spin count to 1 for ManualResetEventSlim. This drastically reduce…
…s CPU usage on mono and increases write speeds by ~50%.

@Lougarou Lougarou merged commit a9eac03 into master Jan 25, 2019

@Lougarou Lougarou deleted the manualreseteventslim-fix branch Jan 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment