Exit DrainPacketQueue thread when build completes.#12561
Merged
JanProvaznik merged 2 commits intodotnet:mainfrom Nov 4, 2025
Merged
Exit DrainPacketQueue thread when build completes.#12561JanProvaznik merged 2 commits intodotnet:mainfrom
JanProvaznik merged 2 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a thread management issue where DrainPacketQueue threads were not being properly terminated when builds complete, causing thread accumulation during repeated builds. The fix ensures the dedicated thread exits when it receives a NodeBuildComplete packet.
Key changes:
- Added explicit thread termination logic for
NodeBuildCompletepackets - Added thread naming for better debugging visibility
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs
Show resolved
Hide resolved
rainersigwald
approved these changes
Oct 27, 2025
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
|
/backport to vs18.3 |
Contributor
|
Started backporting to |
This was referenced Nov 5, 2025
SimaTian
added a commit
that referenced
this pull request
Nov 6, 2025
Backport of #12561 to vs18.3 /cc @rainersigwald @Erarndt --------- Co-authored-by: Eric Arndt <erarndt@microsoft.com> Co-authored-by: Tomas Bartonek <tom.bartonek@volny.cz>
Member
|
/backport to vs18.0 |
Contributor
|
Started backporting to |
rainersigwald
added a commit
that referenced
this pull request
Nov 14, 2025
Backport of #12561 to vs18.0 Work item (Internal use): [devdiv#2613541](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2613541) ### Summary MSBuild communications threads were incorrectly not exiting when builds completed. ### Customer Impact Memory leak that gets worse with each build or design-time build operation. ### Regression? Yes, from 17.14. ### Testing Unit tests, manual testing, already inserted into 18.3 builds. ### Risk Low. --------- Co-authored-by: Eric Arndt <erarndt@microsoft.com> Co-authored-by: Rainer Sigwald <raines@microsoft.com>
This was referenced Nov 19, 2025
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.
Fixes #
Context
Currently, the dedicated thread that handles processing the packet queue doesn't exit properly when build finishes. The threads are idle, but repeated builds create a new thread each time and they accumulate during the session:
The check for
IsExitPacket()is slightly misleading since it checks for more than just the completion of the buildBy explicitly checking for the
NodeBuildCompletepacket, we can exit the processing loop and let the thread get cleaned up. Additionally, I named the dedicated thread to help identify issues like this in the future.Changes Made
Testing
Notes