Skip to content

Shorten thread names exceeding the 15-char Linux pthread_setname_np limit#125928

Merged
danmoseley merged 5 commits intomainfrom
copilot/shorten-thread-names
Mar 24, 2026
Merged

Shorten thread names exceeding the 15-char Linux pthread_setname_np limit#125928
danmoseley merged 5 commits intomainfrom
copilot/shorten-thread-names

Conversation

Copy link
Contributor

Copilot AI commented Mar 22, 2026

Linux silently truncates thread names to 15 characters via pthread_setname_np, making several runtime threads indistinguishable in ps, top, htop, and debuggers.

Description

Renamed six thread names that exceeded the limit across all affected files, including the Mono browser WASM runtime:

Old Name New Name
.NET Stack overflow trace logger (33) .NET SO Tracer (14)
.NET Stack overflow create dump (32) .NET SO Dumper (14)
.NET Tiered Compilation Worker (30) .NET Tiered JIT (15)
.NET Long Running Task (22) .NET Long Task (14)
.NET ThreadPool IO (18) .NET TP I/O (11)
.NET SynchManager (18) .NET Sync Mgr (13)

All other runtime thread names (.NET TP Worker, .NET Finalizer, .NET EventPipe, etc.) were already within the limit and are unchanged.

The rename of .NET Long Running Task.NET Long Task is also applied in src/mono/browser/runtime/pthreads/worker-thread.ts, which hardcodes the name to identify long-running threads in the Mono browser WASM threading layer.

Original prompt

This section details on the original issue you should resolve

<issue_title>Shorten thread names that exceed the 15-char Linux limit</issue_title>
<issue_description>> [!NOTE]

This issue was created with Copilot assistance.

Linux limits thread names to 15 characters (plus null terminator) via pthread_setname_np. Several runtime thread names exceed this and get silently truncated, making them indistinguishable in debuggers and diagnostic tools like ps, top, and htop.

(macOS allows 63 chars, FreeBSD allows 32 — Linux is the strictest.)

Current Name Len Suggested Name Len Location
.NET Stack overflow trace logger 33 .NET SO Tracer 14 src/coreclr/vm/eepolicy.cpp
.NET Stack overflow create dump 32 .NET SO Dumper 14 src/coreclr/vm/excep.cpp
.NET Tiered Compilation Worker 30 .NET Tiered JIT 15 src/coreclr/vm/tieredcompilation.cpp
.NET Long Running Task 23 .NET Long Task 14 ThreadPoolTaskScheduler.cs
.NET ThreadPool IO 18 .NET TP I/O 12 PortableThreadPool.IO.Windows.cs
.NET SynchManager 17 .NET Synch Mgr 14 src/coreclr/pal/src/synchmgr/synchmanager.cpp
.NET TP Worker 14
.NET Finalizer 14
.NET EventPipe 14
.NET DebugPipe 14
.NET Debugger 13
.NET TP Gate 12
.NET TP Wait 12
JSWebWorker 11
.NET Timer 10

Note: The managed debugger may rely on some of these thread names to identify special threads. If so either they should be left unchanged or there will need to be a synchronized debugger change to match.
</issue_description>

Comments on the Issue (you are @copilot in this section)

@jkotas > .NET TC Worker

We should drop the "worker" from the name, it has very little information value. Once we do that, it can something more self-describing like ".NET Tiered JIT".

.NET LR Task

"LR" is very cryptic. Can this be something more self-describing like ".NET Long Task"?

.NET TP I/O

Windows specific. (We can still change the name to make it more similar to other TP names.)</comment_new>
<comment_new>@danmoseley
Any issues with debugger dependency or we can freely change?
I can kick copilot if there's no special considerations</comment_new>
<comment_new>@jkotas
We have tweaked the thread names a few times before and I do not recall debugger or diagnostic tools having an issue with that.</comment_new>


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

- .NET Stack overflow trace logger -> .NET SO Tracer (eepolicy.cpp)
- .NET Stack overflow create dump  -> .NET SO Dumper (excep.cpp)
- .NET Tiered Compilation Worker   -> .NET Tiered JIT (tieredcompilation.cpp)
- .NET Long Running Task           -> .NET Long Task (ThreadPoolTaskScheduler.cs)
- .NET ThreadPool IO               -> .NET TP I/O (PortableThreadPool.IO.Windows.cs)
- .NET SynchManager                -> .NET Synch Mgr (synchmanager.cpp)

Fixes: linux pthread_setname_np silently truncating names > 15 chars

Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/a38ad624-ca24-4ec4-909a-8c3265181984
Copilot AI changed the title [WIP] Shorten thread names that exceed 15-char Linux limit Shorten thread names exceeding the 15-char Linux pthread_setname_np limit Mar 22, 2026
Copilot AI requested a review from danmoseley March 22, 2026 18:02
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Mar 22, 2026

@copilot Review all code and tests in the repo for copies of these strings and update them as appropriate. Note that that string can be shortened.

For example, src\mono\browser\runtime\pthreads\worker-thread.ts has .NET Long Running Task hardcoded string that needs to be updated.

Copy link
Contributor Author

Copilot AI commented Mar 22, 2026

@copilot Review all code and tests in the repo for copies of these strings and update them as appropriate. Note that that string can be shortened.

For example, `src\mono\browser\runtime\pthreads\wo...

Done in 02f058b. Updated src/mono/browser/runtime/pthreads/worker-thread.ts (the only other occurrence) — .NET Long Running Task.NET Long Task. Verified no other copies of the old names remain anywhere in the repo.

Copilot AI requested a review from jkotas March 22, 2026 18:11
Copy link
Member

@danmoseley danmoseley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoyosjs can you confirm no debugger dependency concerns?

@danmoseley
Copy link
Member

Past changes like this
#75113

@danmoseley danmoseley marked this pull request as ready for review March 22, 2026 20:07
Copilot AI review requested due to automatic review settings March 22, 2026 20:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR shortens several internal runtime thread names to fit Linux’s 15-character pthread_setname_np limit so that thread names remain distinguishable in system tools and debuggers, and keeps the Mono browser WASM threading layer in sync for long-running thread identification.

Changes:

  • Renames stack overflow helper threads to shorter, distinct names (.NET SO Tracer, .NET SO Dumper).
  • Renames tiered compilation background worker thread to .NET Tiered JIT (15 chars).
  • Renames managed long-running task thread, Windows threadpool I/O poller thread, and PAL SynchManager worker thread to shorter names (including syncing the WASM worker-thread identification string).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/mono/browser/runtime/pthreads/worker-thread.ts Updates the hardcoded long-running thread name check to match the new runtime thread name.
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs Shortens the dedicated LongRunning task thread name.
src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.IO.Windows.cs Shortens the Windows IO completion poller thread name for consistency and readability.
src/coreclr/vm/tieredcompilation.cpp Shortens the tiered compilation background worker thread name to fit Linux’s limit.
src/coreclr/vm/excep.cpp Shortens the stack overflow “createdump” helper thread name to avoid truncation.
src/coreclr/vm/eepolicy.cpp Shortens the stack overflow stack trace logging helper thread name to avoid truncation.
src/coreclr/pal/src/synchmgr/synchmanager.cpp Shortens the synchronization manager worker thread name to avoid truncation.

Copilot AI requested a review from danmoseley March 22, 2026 23:10
@danmoseley
Copy link
Member

I was curious what the synch manager is and apparently it's the PAL way of simulating Windows cross process synchronization primitives.

@danmoseley danmoseley merged commit 21630d9 into main Mar 24, 2026
154 of 158 checks passed
@danmoseley danmoseley deleted the copilot/shorten-thread-names branch March 24, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shorten thread names that exceed the 15-char Linux limit

6 participants