Fix CPU is consumed by polling frequently when there is no subscriber#4735
Merged
cvpoienaru merged 12 commits intomicrosoft:mainfrom Nov 14, 2023
Merged
Fix CPU is consumed by polling frequently when there is no subscriber#4735cvpoienaru merged 12 commits intomicrosoft:mainfrom
cvpoienaru merged 12 commits intomicrosoft:mainfrom
Conversation
nohwnd
commented
Nov 3, 2023
Member
Author
|
@cvpoienaru Please fix the tests, and re-enable the PreStartCount to 2. 🙏🙇 |
nohwnd
commented
Nov 3, 2023
...rosoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs
Outdated
Show resolved
Hide resolved
nohwnd
commented
Nov 3, 2023
...rosoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs
Outdated
Show resolved
Hide resolved
nohwnd
commented
Nov 3, 2023
...rosoft.TestPlatform.CommunicationUtilities/Interfaces/Communication/ICommunicationChannel.cs
Show resolved
Hide resolved
nohwnd
commented
Nov 3, 2023
src/Microsoft.TestPlatform.CommunicationUtilities/LengthPrefixCommunicationChannel.cs
Show resolved
Hide resolved
nohwnd
commented
Nov 3, 2023
| MessageReceived.SafeInvoke(this, new MessageReceivedEventArgs { Data = data }, "LengthPrefixCommunicationChannel: MessageReceived"); | ||
| } | ||
| else | ||
| { |
Member
Author
There was a problem hiding this comment.
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.
nohwnd
commented
Nov 3, 2023
src/Microsoft.TestPlatform.CommunicationUtilities/TcpClientExtensions.cs
Show resolved
Hide resolved
…ommunication/ICommunicationChannel.cs Co-authored-by: Jakub Jareš <me@jakubjares.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…nd/vstest into Fix-tight-loop-when-waiting
cvpoienaru
approved these changes
Nov 14, 2023
MarcoRossignoli
approved these changes
Nov 14, 2023
ThorstenSauter
referenced
this pull request
in ThorstenSauter/NoPlan
Feb 6, 2024
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [Microsoft.Identity.Web](https://togithub.com/AzureAD/microsoft-identity-web) | `2.16.1` -> `2.17.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | | [Microsoft.NET.Test.Sdk](https://togithub.com/microsoft/vstest) | `17.8.0` -> `17.9.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>AzureAD/microsoft-identity-web (Microsoft.Identity.Web)</summary> ### [`v2.17.0`](https://togithub.com/AzureAD/microsoft-identity-web/blob/HEAD/changelog.md#2170) [Compare Source](https://togithub.com/AzureAD/microsoft-identity-web/compare/2.16.1...2.17.0) \========= - Updated to Microsoft.IdentityModel.\* 7.3.1 and MSAL.NET 4.59.0 ##### New features - Added support for Microsoft.NET.Sdk.Worker. See [Worker calling APIs](https://togithub.com/AzureAD/microsoft-identity-web/wiki/worker%E2%80%90app%E2%80%90calling%E2%80%90downstream%E2%80%90apis) - Added support for Managed identity when calling a downstream API on behalf of the app. See [Calling APIs with Managed Identity](https://togithub.com/AzureAD/microsoft-identity-web/wiki/calling-apis-with-managed-identity) and [PR 2650](https://togithub.com/AzureAD/microsoft-identity-web/pull/2650). For details see [PR #​2645](https://togithub.com/AzureAD/microsoft-identity-web/issues/2645) ##### Bug fixes - In OWIN applications, GetTokenForUserAsync now respects the ClaimsPrincipal. See issue [#​2629](https://togithub.com/AzureAD/microsoft-identity-web/issues/2629) for details. - After setting `AddTokenAcquisition(useSingleton:true)` to use token acquisition as a singleton, if you use `.AddMicrosoftGraph` and/or `.AddDownstreamApi` after this call, the GraphServiceClient and IDownstreamApis are now registered as a singleton service. For details see [PR #​2645](https://togithub.com/AzureAD/microsoft-identity-web/issues/2645) - Added check Against Injection Attacks. For details see [PR 2619](https://togithub.com/AzureAD/microsoft-identity-web/issues/2619) ##### Engineering excellence - Added a benchmark running on PR merges, available from <https://azuread.github.io/microsoft-identity-web/benchmarks> on GitHub pages </details> <details> <summary>microsoft/vstest (Microsoft.NET.Test.Sdk)</summary> ### [`v17.9.0`](https://togithub.com/microsoft/vstest/releases/tag/v17.9.0) ##### What's Changed - Remove dependency on Nuget.Frameworks by [@​nohwnd](https://togithub.com/nohwnd) in [https://github.com/microsoft/vstest/pull/4693](https://togithub.com/microsoft/vstest/pull/4693) - Add platform guard by [@​dotMorten](https://togithub.com/dotMorten) in [https://github.com/microsoft/vstest/pull/4737](https://togithub.com/microsoft/vstest/pull/4737) - Remove javascript in `HtmlLogger` by [@​daveMueller](https://togithub.com/daveMueller) in [https://github.com/microsoft/vstest/pull/4744](https://togithub.com/microsoft/vstest/pull/4744) - Fix CPU is consumed by polling frequently when there is no subscriber by [@​nohwnd](https://togithub.com/nohwnd) in [https://github.com/microsoft/vstest/pull/4735](https://togithub.com/microsoft/vstest/pull/4735) - Create a proper MSBuild ToolTask based VSTestTask by [@​mcartoixa](https://togithub.com/mcartoixa) in [https://github.com/microsoft/vstest/pull/2702](https://togithub.com/microsoft/vstest/pull/2702) - Update SDK, copy logger by [@​nohwnd](https://togithub.com/nohwnd) in [https://github.com/microsoft/vstest/pull/4755](https://togithub.com/microsoft/vstest/pull/4755) - Fix staircase in logger by [@​nohwnd](https://togithub.com/nohwnd) in [https://github.com/microsoft/vstest/pull/4756](https://togithub.com/microsoft/vstest/pull/4756) - Update dump client to latest by [@​nohwnd](https://togithub.com/nohwnd) in [https://github.com/microsoft/vstest/pull/4724](https://togithub.com/microsoft/vstest/pull/4724) - \[rel/17.9] Disable testhost prestart by [@​nohwnd](https://togithub.com/nohwnd) in [https://github.com/microsoft/vstest/pull/4836](https://togithub.com/microsoft/vstest/pull/4836) ##### New Contributors - [@​jithu7432](https://togithub.com/jithu7432) made their first contribution in [https://github.com/microsoft/vstest/pull/4698](https://togithub.com/microsoft/vstest/pull/4698) - [@​mcartoixa](https://togithub.com/mcartoixa) made their first contribution in [https://github.com/microsoft/vstest/pull/2702](https://togithub.com/microsoft/vstest/pull/2702) **Full Changelog**: microsoft/vstest@v17.8.0...v17.9.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ThorstenSauter/NoPlan). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNzMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjE3My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This was referenced Mar 17, 2026
Open
Bump Microsoft.NET.Test.Sdk from 16.9.4 to 17.13.0
harshaun/skills-secure-repository-supply-chain#10
Open
Open
Open
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 = 1or 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