-
Notifications
You must be signed in to change notification settings - Fork 340
Fix CPU is consumed by polling frequently when there is no subscriber #4735
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
Fix CPU is consumed by polling frequently when there is no subscriber #4735
Conversation
@cvpoienaru Please fix the tests, and re-enable the PreStartCount to 2. 🙏🙇 |
...rosoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs
Outdated
Show resolved
Hide resolved
...rosoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs
Outdated
Show resolved
Hide resolved
...rosoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs
Show resolved
Hide resolved
src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs
Show resolved
Hide resolved
MessageReceived.SafeInvoke(this, new MessageReceivedEventArgs { Data = data }, "LengthPrefixCommunicationChannel: MessageReceived"); | ||
} | ||
else | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is unnecessary, and way too much detail. with prestart it is normal that client is waiting for his turn and this would just add yet another message to the log that would always repeat.
src/Microsoft.TestPlatform.CommunicationUtilities/TcpClientExtensions.cs
Show resolved
Hide resolved
…ommunication/ICommunicationChannel.cs Co-authored-by: Jakub Jareš <[email protected]>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
…nd/vstest into Fix-tight-loop-when-waiting
Description
We disabled pre-started testhosts in 17.6.0 because the waiting host could consume large amounts of CPU when data were waiting on the pipeline and there were no consumers on vstest.console side. This is easy to reproduce when you set
VSTEST_HOSTPRESTART_COUNT = 1
or more, and enable diagnostic logs.What happens is that we run init on the pre-started testhost and after we remove the CheckVersionWithHost subscriber, the diag log will push TestMesage: Logging TestHost Diagnostics in file... which will be wating on the wire and causing tight loop of notifications to subscriber that is not there.
In logs this shows up like this, with 0ms since the last poll, because the Poll returns immediately, and the notification as well, causing this tight loop:
Instead of this we add a flag that will wait for the maximum of 1 second for a subscriber to subscribe to data reading, and if that does not happen we repeat the loop.
In log it shows like this:
Where we correctly wait for the subscriber to subscribe. We also return immediately when we are being cancelled.
There are probably other causes for this to happen, but this should solve all of them.
Related issue
Fix https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1896342
Fix https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1835463