Repository navigation
Conversation
Compare process-level isolation and shared TaskHosts with task-ID routing for forwarding IBuildEngine3.Yield/Reacquire from out-of-process TaskHosts, and recommend the shared-host design with shared-state mitigations. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Correct benchmark interpretation, process boundaries, and shared-state safeguards. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
|
||
| ## Open questions | ||
|
|
||
| - Should Option B allow a task to request a separate TaskHost when it cannot follow the shared-state rule? |
There was a problem hiding this comment.
Don't we already differentiate between "explicit taskhost" and "sidecar taskhost"? The decision here could be whether you're sidecar.
| The callback model does not cover explicit `Yield`: | ||
|
|
||
| - `IBuildEngine3.Yield()` and `Reacquire()` are no-ops in the TaskHost. A callback blocks the calling thread, although other threads created by the task can still run. | ||
| - A truly yielded task continues to run while another task is active in the same process. The yielded task can log or complete during that time. |
There was a problem hiding this comment.
Isn't it always an error to complete while yielded? I thought we required Reacquire.
There was a problem hiding this comment.
The agent during implementation (and now during additional design review) found several cases where that check isn't done - if we strengthened those checks then some implementation cost/code size may shrink.
I've added a bit more detail about yielding today and the engine level checks to this doc to highlight the gaps and potential for strengthening the engine behaviors.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Thanks for writing this up and building both prototypes — the C++ clean-build regression (~39 s → ~100–117 s) is clearly real, and having both prototypes makes the trade-offs much easier to evaluate. High-level take / Scoping recommendationOverall, enabling arbitrary TaskHost yielding by default introduces substantial risk (both shared-state corruption under Option B and subtle feature/lifetime interactions across the whole TaskHost surface). Before committing to general-purpose TaskHost yielding by default, we should seriously consider scoping this as opt-in only for known yielding, non-migrated tasks in the C++ scenario — if we verify that existing/older C++ tasks will actually be used with new MSBuild in this mode (rather than migrating/updating them) — instead of turning it on for all tasks by default. 1. Principled protocol & handshake design firstBoth prototypes end up adding stateful prefix packets ( We should figure out the principled handshake and protocol-versioning story first — alongside the type-safe MSBuild node handshakes proposal and the CLR4 cross-version issues raised on #15586 — before locking in 2. Task-ID routing, Option A vs. B, and isolation boundaries
3. Feature interactions at risk (needs explicit tracing & design)Whichever design (or opt-in scope) we pick, these existing MSBuild features interact directly with TaskHost yielding and are currently at risk in the prototypes:
4. Additional Requirement: ETW InstrumentationPlease add ETW events to the common requirements (consistent with
5. Checklist of Invariants to Validate in the Final ImplementationBefore any implementation PR merges, it should validate all of the following:
6. Open Questions to Resolve in the Spec
|
Related issue(s):
None.
Context
CLandMIDLyield their node while an external compiler runs, so another project can use that capacity. In an out-of-process TaskHost,YieldandReacquireare no-ops. The node stays reserved instead.On a 104-project workload at
-m:8, clean builds took 39.2 s in-process, 99.4 s withMSBuild.exe -mt, and about 103-104 s in the later yield-disabled comparison.Start with the diagrams: in-process overlap versus current TaskHost behavior.
Changes Made
Documentation only. The spec explains why yielded-task lifetime, process state, routing, scheduler accounting, and memory need design decisions.
The recommendation favors B only if its shared-state risk is acceptable. Tests and diagnostics cannot enforce isolation.
Review questions: accept that risk or choose A, provide per-task isolation, and decide whether balanced completion needs engine-level enforcement. The no-op differences remain unexplained.
The spec retains the existing-callback comparison, reacquire constraints, benchmark provenance, rebased prototype links, and links from the related threading specs.
Compatibility
No product behavior changes. The proposed implementations negotiate packet version 9, retain no-op behavior for older and CLR2 hosts, and provide a change wave 18.14 opt-out.
Testing
git diff --check- passed.mmdc -i documentation\specs\multithreading\taskhost-yield.md -o "$env:TEMP\taskhost-yield-05c023a1-review.md" -e svg --quiet- passed. All four diagrams render and were visually checked.Local benchmark evidence, not committed:
C:\Users\chusk\.copilot\session-state\daf19032-ba4c-47ec-a9d5-50e049a6d4d7\files\native-cpp-yield\measure-141146-a42b7f(normal mode, four rounds)C:\Users\chusk\.copilot\session-state\0d839b1c-0964-4ff4-a89f-5b16e337e413\files\native-cpp-yield-mt\measure-163107-c7fbd4(-mt, two rounds)Runs were sequential, not concurrent, with variant order varied. Sample counts are small.
Dependencies and Follow-up
Select the isolation design before an implementation PR. Both prototypes build on the CLR4 TaskHost support parent identified in the spec.