Skip to content

Add descriptive names to MSBuild thread instances for debugging and performance tracing#12

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/name-inproc-node-threads
Draft

Add descriptive names to MSBuild thread instances for debugging and performance tracing#12
Copilot wants to merge 4 commits intomainfrom
copilot/name-inproc-node-threads

Conversation

Copy link

Copilot AI commented Dec 5, 2025

Context

MSBuild creates numerous threads across different components. Without descriptive names, debugging multithreaded builds and analyzing performance traces requires correlating thread IDs with source code, which is time-consuming and error-prone. Most threads already had names, but two critical schedulers were missing them.

Changes Made

Added thread naming to the two remaining unnamed thread creation sites:

  • RequestBuilder's DedicatedThreadsTaskScheduler: Names threads as "MSBuild RequestBuilder Task Scheduler Thread {id}" for task execution scheduling
  • AwaitExtensions' OneSTAThreadPerTaskScheduler: Names threads as "MSBuild STA Task Scheduler Thread {id}" for STA-required task execution

Both implementations use Interlocked.Increment for thread-safe ID generation.

// RequestBuilder.cs
private int _threadCount = 0;

private void InjectThread()
{
    int currentThreadId = Interlocked.Increment(ref _threadCount);
    var thread = new Thread(() => { /* ... */ });
    thread.Name = $"MSBuild RequestBuilder Task Scheduler Thread {currentThreadId}";
    thread.Start();
}

Testing

  • Full build passes
  • RequestBuilder unit tests pass
  • Sample project builds work correctly

Notes

All MSBuild threads now have descriptive names. The existing 10 named thread types remain unchanged.

Original prompt

there are a bunch of threads utilized in MSBuild, give them descriptive names so tracing perf and debugging is easy. Especially i'm interested in in-proc node threads that build the projects in multithreaded mode, but analyze and name other cases too


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 5, 2025 15:41
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Copilot AI changed the title [WIP] Add descriptive names for in-proc node threads Add descriptive names to MSBuild thread instances for debugging and performance tracing Dec 5, 2025
Copilot AI requested a review from JanProvaznik December 5, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants