Skip to content
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

Increasing CPU when using thread pool statistics #49

Closed
danielwidmann opened this issue Dec 14, 2020 · 8 comments
Closed

Increasing CPU when using thread pool statistics #49

danielwidmann opened this issue Dec 14, 2020 · 8 comments

Comments

@danielwidmann
Copy link

This might be related to #6, but I'm not sure as .net core 3.1 is used.

We run prometheus-net.DotNetRuntime in an alpine linux docker container with dotnet core 3.1. We noticed the CPU usage is slowly increasing over time. The situation significantly improves when thread pool stats are not collected (see plot below), but even then there still is a measurable increase in CPU usage. There doesn't seem to be a measurable increase in memory consumption.

Initialization with thread pool stats:

collector = DotNetRuntimeStatsBuilder
                .Customize()
                .WithContentionStats()
                .WithJitStats()
                .WithThreadPoolSchedulingStats()
                .WithThreadPoolStats()
                .WithGcStats()
                .WithExceptionStats()
                .StartCollecting();

Initialization without thread pool stats:

collector = DotNetRuntimeStatsBuilder
                .Customize()
                .WithJitStats()
                .WithGcStats()
                .WithExceptionStats()
                .StartCollecting();

CPU increse_2

We also did some CPU profiling on the affected system, but unfortunately 99% of the CPU time is spend in unmanaged code.
image

Any ideas how the increase in CPU could be avoided while still collecting metrics? Or any idea how to further investigate this issue?

@djluck
Copy link
Owner

djluck commented Feb 10, 2021

What version of .NET 3.1 is the container using? Version < 3.1.5 has a memory leak that can cause this CPU consumption you're experiencing (see this MR dotnet/runtime#35924).

@danielwidmann
Copy link
Author

We are using 3.1.10.

# dotnet --info

Host (useful for support):
  Version: 3.1.10
  Commit:  1721e39439

.NET Core SDKs installed:
  No SDKs were found.

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

@djluck
Copy link
Owner

djluck commented Feb 10, 2021

Would it be possible to share the full trace you collected with me?

@danielwidmann
Copy link
Author

I sent you an email.

@djluck
Copy link
Owner

djluck commented Feb 11, 2021

So that trace was collected with dotnet-trace and doesn't include CPU time. To analyze cpu-bound issues, you should use the perfcollect script- https://docs.microsoft.com/en-us/dotnet/core/diagnostics/trace-perfcollect-lttng.

@djluck
Copy link
Owner

djluck commented Feb 11, 2021

This does look similar to the CPU overconsumption issue that we saw in earlier .NET core versions, not sure why it's popping back up. I need to dedicate some time to look at this properly at some point.

@linys2333
Copy link

I found the same problem!Don't know how to solve it.

@djluck
Copy link
Owner

djluck commented Mar 21, 2021

This issue duplicates #6, so closing it. V4 should resolve the issues described here.

@djluck djluck closed this as completed Mar 21, 2021
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

No branches or pull requests

3 participants