Stop TerminalLogger from opting into task input logging#13686
Stop TerminalLogger from opting into task input logging#13686
Conversation
|
Hello @copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
TerminalLogger and ForwardingTerminalLogger called IEventSource3.IncludeTaskInputs() but never consume TaskParameterEventArgs. The opt-in caused the engine to set LogTaskInputs=true, serializing every task's parameters (including potentially large ItemGroups with metadata) into events for every task invocation. On builds with hundreds of MSBuild task invocations (e.g. dotnet/source-build-assets), this produced ~100x slowdown vs the console logger which doesn't opt in. Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/83339a52-7c6c-4b00-947f-9c1521eecae8 Co-authored-by: ViktorHofer <7412651+ViktorHofer@users.noreply.github.com>
baronfel
left a comment
There was a problem hiding this comment.
I'd be hesitant to take this - several of my draft PRs build on Task input detection in order to enable nicer end user UX.
If we do disable this because of perf we'd just reenable it on those PRs. Is the cost all of the IPC? If so, then MT should solve that problem? Or keep this code and instead make the 'forwarding logger' part of the TL today drop all Task input events at the individual worker node to prevent them being sent to the central logger node.
|
I see two options:
|
Yes — the cost is not just IPC, and that's the key reason filtering in the forwarding logger isn't a complete fix. The hot gate is in if (LogTaskInputs && !_taskLoggingContext.LoggingService.OnlyLogCriticalEvents)
{
...
ItemGroupLoggingHelper.LogTaskParameter(...);
}When
Steps 1–3 happen on the worker even before any IPC. With hundreds of
The reason flipping Re: your draft PRs that do consume task-input events — agreed, and I don't want to block that. Two options that compose with this PR:
I'm happy to switch to (2) if you'd prefer — just say the word and tell me which trigger you want (verbosity ≥ Detailed? a |
|
OK, that's a fine analysis. We can land this for now. |
|
One thing to note for future work - when in MT mode it seems highly likely that message creation could be closer to zero-copy, so we should look at making message creation more like a 'view' over data that is 'hydrated' only in the out-of-proc IPC scenario. |
|
/review |
|
✅ Expert Code Review (command) completed successfully! Expert review of PR #13686 completed by subagent. The PR is a correct, clean fix removing unused |
There was a problem hiding this comment.
Pull request overview
This PR removes the IEventSource3.IncludeTaskInputs() opt-in from both TerminalLogger and ForwardingTerminalLogger, preventing MSBuild from globally enabling task-parameter event emission (TaskParameterEventArgs) when the terminal logger is present. This aligns logger opt-ins with actual event consumption and avoids significant overhead from serializing large task input payloads.
Changes:
- Removed
IncludeTaskInputs()fromTerminalLogger.InitializesinceTaskParameterEventArgsare not consumed. - Removed
IncludeTaskInputs()fromForwardingTerminalLogger.Initializefor the same reason. - Kept
IEventSource4.IncludeEvaluationPropertiesAndItems()since evaluation properties/items are consumed viaProjectEvaluationFinishedEventArgs.
Show a summary per file
| File | Description |
|---|---|
| src/Build/Logging/TerminalLogger/TerminalLogger.cs | Stops terminal logger from opting into task-input events it never consumes, reducing task-parameter logging overhead. |
| src/Build/Logging/TerminalLogger/ForwardingTerminalLogger.cs | Stops forwarding terminal logger from opting into task-input events it never consumes, reducing overhead on node builds as well. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
Context
TerminalLogger.InitializeandForwardingTerminalLogger.Initializeopt intoIEventSource3.IncludeTaskInputs(), but neither class ever consumesTaskParameterEventArgs. The opt-in flipsLogTaskInputs = truein the engine (ProjectInstance.cs:2822), forcing serialization of every task's parameters — including largeItemGroups with metadata — into events on every task invocation.On builds with hundreds of
MSBuildtask invocations (e.g.dotnet/source-build-assets), this is what produces the reported ~100× slowdown vs. the console logger, which never opts in.Changes Made
eventSource3.IncludeTaskInputs()call fromTerminalLogger.Initialize.ForwardingTerminalLogger.Initialize.IncludeEvaluationPropertiesAndItems()opt-in — it's actually consumed viaProjectEvaluationFinishedEventArgs.EnumerateProperties().Testing
TerminalLogger_Testspass.Notes
A grep over
src/Build/Logging/TerminalLogger/confirms no reference toTaskParameterEventArgsor task parameter consumption — the opt-in was dead overhead.TaskCommandLineEventArgs(used by_showCommandLine) is unrelated and not gated byIncludeTaskInputs.