Allow NodeProviderOutOfProcTaskHost to manage multiple nodes instead of one per arch#12521
Allow NodeProviderOutOfProcTaskHost to manage multiple nodes instead of one per arch#12521surayya-MS wants to merge 8 commits intodotnet:mainfrom
NodeProviderOutOfProcTaskHost to manage multiple nodes instead of one per arch#12521Conversation
previously _nodeContext was dict with key of HandshakeOptions, now it is nodeId, previously NodeProviderOutOfProcTaskHost allowed max 4 nodes depending on the arch and etc., now it is unlimited
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the NodeProviderOutOfProcTaskHost class to support managing multiple nodes dynamically rather than being limited to exactly 4 nodes. The change removes the hardcoded MaxNodeCount = 4 limitation and introduces proper node ID management.
Key Changes
- Replaced
HandshakeOptionsenum-based node identification with integer-based node IDs - Removed the hardcoded maximum node count limitation of 4 nodes
- Updated the node management system to use
ConcurrentDictionarywith proper locking mechanisms
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| TaskHostTask.cs | Updated to use integer node IDs instead of HandshakeOptions for communication with task host provider |
| NodeProviderOutOfProcTaskHost.cs | Refactored node management system to support unlimited nodes with proper concurrent access and ID generation |
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs
Outdated
Show resolved
Hide resolved
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs
Outdated
Show resolved
Hide resolved
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs
Outdated
Show resolved
Hide resolved
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs
Outdated
Show resolved
Hide resolved
|
Changed Message task to append Process id for manual validation (did't commit this change) |
NodeProviderOutOfProcTaskHost to manage multiple nodes instead of one per arch
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs
Outdated
Show resolved
Hide resolved
|
Let's also check that taskhosts are reused properly during the build - project which has multiple message tasks, during the build with /mt /m should print have same process ID. |
I added second message to each of the projects. The result is different process ids for messages from the same project. I then checked same without -mt, and the result is the same. But in main without -mt, the result in is same process id for tasks from the same project. |
src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs
Outdated
Show resolved
Hide resolved
|
From the previous results: Before the multi-threaded mode was introduced, there was one node per process , and the node to reuse in We need to somehow pass on nodeId (in-proc) to |
| { | ||
| // node already exists, so "creation" automatically succeeded | ||
| nodeCreationSucceeded = true; | ||
| nodeId = _nextNodeId++; |
There was a problem hiding this comment.
consider https://learn.microsoft.com/en-us/dotnet/api/system.threading.interlocked.increment?view=net-9.0 instead of the lock
| private HandshakeOptions _requiredContext = HandshakeOptions.None; | ||
| private HandshakeOptions _requiredHandshakeOptions = HandshakeOptions.None; | ||
|
|
||
| private int _requiredNodeId = -1; |
There was a problem hiding this comment.
this naming is confusing, if you want to express that a specific taskhosttask has a mapping to a nodeId, then I'd just say something like _taskHostNodeId
|
Closing this in favor of #12577 |
Fixes #12552
Context
Changes Made
Testing
Notes