-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to include all threads in dotnet-stack reports #5193
Comments
There's two parts to this:
|
The total counts from
are significantly higher than the total number of threads listed in the dotnet-stack output. I don't think the lack of native threads is the only reason behind the difference. The total count of threads with names that look like managed threads is higher than what is included in dotnet-stack. I wonder if there is a way to clearly identify which ones of those are managed or native-only. |
I couldn't find a way to split them, so the best I could do was
vs
269 vs 389. The commands ran within a few seconds of each other. For what is worth |
It seems that a big reason behind the difference in values is caused by threads with no stack frames. As per
If I exclude these from the I don't know what the threads with no clr stack represent. |
LLDB/Windbg could give us hints - we'd need to see what things like |
Thanks. It seems they are all related to GC. Here is a stacktrace:
96 threads in this situation. It seems there is one BGC thread per core as this machine has 96 cores. Not sure if this is the optimal number of BG GC threads. In the JVM it is possible to define the number of background GC threads. I didn't find such option in dotnet. |
Sorry @andredasilvapinto - I thought I had replied to this. There's GcHeapCount in GC Configs. Additionally, there's a new GC mode DATAS that adapts the heap count dynamically to pressure. |
Background and Motivation
We monitor the number of process threads via
Process.GetCurrentProcess().Threads.Count
and have been noticing a continuous increase in this metric, which seems to indicate a potential thread leak. In order to investigate this, I tried using dotnet-stack, but the total number of stack frames that it prints is much smaller than what is reported by the Threads.Count metric or the output ofps -T -p <PID>
on Linux.The documentation for report says:
Prints the stack trace for each thread in the target process.
which doesn't seem to be correct.
By looking at the (short) thread names, I can see that for example none of the ".NET Server GC" or ".NET BGC" are reported, but there are more cases. It is difficult to know exactly which threads are missing as dotnet-stack does not include the thread name in its output (something that would also be very useful and is present in the JVM equivalent
jstack
).It would be useful to provide an option to output the exhaustive list of all threads in the process.
Proposed Feature
Add option to include all process threads in the
dotnet-stack report
outputThe text was updated successfully, but these errors were encountered: