-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
HostMetrics process scraper high CPU usage during collection on Windows Server 2019 #32947
Comments
Pinging code owners: See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Hi @drewftw, I made improvements to the CPU usage of the process scraper in v0.99.0 of the collector. Would you be able to update the collector and give that a try? Hopefully that should make it better. |
Hey @braydonk, thanks for your quick response! Sure I can try v0.99 and see if it helps the issue. I've been testing with v0.94 since thats the version my users are on, they haven't upgraded yet |
Here's the issue with the explanation for the CPU usage and how it was fixed in v0.99.0. #28849 We can't be 100% sure you aren't running into something different since this was focused on Linux, but it's worth seeing if this helps in your scenario. |
@braydonk We're still observing a similar pattern after upgrading to v0.99.0. CPU spiking to 5% when metrics are being scraped. Anything I can investigate to provide more info? ![]() |
Thanks for the info @drewftw. I don't expect I'll need anything from your environment; I expect this is the same thing many users are experiencing rather than a specific breakage. The inefficiencies that existed on Linux may exist in different ways on Windows. I'll replicate the same research I did on Linux in my Windows environment. I expect I can set aside some time next week, I will keep this issue updated with progress. |
I had time to investigate this today and I opened a PR with details and a fix! |
Removed |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners: See Adding Labels via Comments if you do not have permissions to add labels yourself. |
This issue has been closed as inactive because it has been stale for 120 days with no activity. |
Not Stale. The PR for this is open and ready for review. Can be marked stale-exempt. |
We are getting hit by this issue as well. It would be a shame to have to pivot to something like the Prometheus Windows Exporter to capture these metrics. I suppose we could fork the code for this scraper, which would also be less then ideal. |
What would your plan be if you were forking? My experiment in #35337 turned out not to pay off; the memory usage of WMI ends up being really high anyway so there wasn't really any gain overall. Do you have any other ideas? I could take just the portion of that PR that worked, which was detecting if the Parent PID resource attribute was disabled and skipping collection, which did have big performance gains provided you don't need that Parent PID. |
The high level plan was to start playing with the PR as a base and see if that helped our issues. However, seeing that your tests didn't result in the performance gains, not sure we would stumble across something the sme's have not already tried. So, we are back to square one.
We would be happy to try this to see if it helps us. |
Further tinkering has show that even if we disable all the default metrics, the CPU usage is still high. The scraper seems to be running, however, ignoring, we figure. Additionally, hosts where CPU usage is high, those hosts have ~800 process running. Hosts with ~100 processes are not affected. We thought we would share in case this helped. |
Were you trying that with the PR from earlier? Because if not, disabling any metrics or resource attributes does not stop the scraper from collecting the expensive attribute, which is the Parent PID. I'm working on a PR that will make it so the Parent PID is not collected if that resource attribute is disabled, which should reduce CPU usage. In my testing on the PR above with the parent PID disabled, it seemed pretty effective. |
I went back and redid my old experiments to evaluate the tradeoffs of #35337, I think I was overestimating how badly WMI is affected. I don't think it actually "outpaces" the CPU gains on the collector; the usage goes up but it really doesn't seem that bad actually (green = no fix, red = fix, blue = wmi): Even graphing other metrics like (Side note: idk why the working set of the collector with the fix is so much lower, I didn't think my fix would have that impact). The main Now it might be that WMI does some manner of optimization holding onto old data or something, maybe this wasn't scientific enough. I can definitely use something like Windows Performance Recorder to do some more in-depth science on this. But with this in mind, I'm inclined to actually revive my old PR instead. I feel a bit more confident that the change is a net-positive. I will rebase the PR to current HEAD and start to address the comments there. |
To close the loop we did not try the PR, we will wait for your changes before trying again. |
One suggestion for a roadmap for the process scraper on Windows is described at #35337 (comment) |
Component(s)
receiver/hostmetrics
What happened?
Description
Otel Collector running on Windows Server 2019 was observed to have high CPU spikes (3-7%) each time the hostmetrics receiver collection process ran which was set to an interval of 1 minute.
After testing the issue was narrowed down to the
process
scraper. The following shows the Otel collector CPU usage when only theprocess
scraper is enabled.After reenabling all other hostmetrics scrapers except for the
process
scraper, we can see the magnitude of the CPU spikes come down significantly (<0.5%).Steps to Reproduce
On a machine running Windows Server 2019, download the
v0.94
version of Otel collector from https://github.com/open-telemetry/opentelemetry-collector-releases/releases/tag/v0.94.0.Modify the
config.yaml
to enable the hostmetricsprocess
scraper and set the collection interval (see config attached to the issue for an example).Run the otel collector exe
Monitor the CPU usage of the otel collector on Task Manager or graph the usage using perfmon
Expected Result
CPU usage comparable to observed levels on Linux collectors (<0.5%)
Actual Result
CPU spikes to 3-7%
Collector version
v0.93.0
Environment information
Environment
OS: Windows Server 2019
OpenTelemetry Collector configuration
Log output
No response
Additional context
Additional details: Windows 2019 was running on an m5x.large EC2
The text was updated successfully, but these errors were encountered: