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

Strange Topbeat (v1.2.1) Performance (under Windows) #1460

Closed
loms0815 opened this issue Apr 22, 2016 · 6 comments
Closed

Strange Topbeat (v1.2.1) Performance (under Windows) #1460

loms0815 opened this issue Apr 22, 2016 · 6 comments
Assignees

Comments

@loms0815
Copy link

loms0815 commented Apr 22, 2016

Hi,
I have configured Topbeat with FILE output only:
Test OS is Windows 7 Enterprise and Topbeat version is v1.2.1.

input:
  period: 15
  procs: [".*"]
  stats:
    system: true
    process: true
    filesystem: true
    cpu_per_core: false

If I specify the "procs"-regex-filter with ".*", then I see no CPU consumption (great). Only every 15secs there is a short spike because of storing to file.

If I configure the "procs"-regex-filter with any other filter (e.g. ".Notepad." or "Notepad") then I got a permanent CPU consumption over 5%.

So the output of all processes is much faster than to take only one process. But I can't configure all processes because in this case the file size is growing to fast!

Can you help me overcome this issue?

@ruflin ruflin added the Topbeat label Apr 25, 2016
@tsg
Copy link
Contributor

tsg commented Apr 25, 2016

@loms0815 Out of curiosity, how many processes are there in total?

@loms0815
Copy link
Author

loms0815 commented Apr 25, 2016

Hi @tsg,

if I specify filter ".*" I will get about 140 processes (=> 140 output lines in json output file) and in this usecase performance is very good!
withnoprocessfilter

If I try to filter to one of the processes (e.g. "Notepad"), I will get this strange cpu consumption.
withsimplenotepadfilter

Interesting is also the IO-Screen. Filtering seems to need a lot of IO?
(FYI: Topbeat interval is 10s)

@andrewkroh
Copy link
Member

The I/O usage seems odd. Here are relevant parts of the process filtering code.

https://github.com/elastic/beats/blob/master/topbeat/system/process.go#L220
https://github.com/elastic/beats/blob/master/topbeat/system/process.go#L160

There are some optimizations that could be made around the filtering. But maybe we should just consider removing it in favor of the conditional filtering being added now.

@loms0815
Copy link
Author

loms0815 commented Apr 25, 2016

Hi @andrewkroh,
I would appreciate this conditional filtering very much! I have already searched for that!
E.g. I had the usecase to get the statistics of only on disk on an linux system. But I had to take the 20 disk of the linux. So my data file was filled up with a lot of unnecessary information.
Conditional filtering would be a great solution for that.

@tsg
Copy link
Contributor

tsg commented May 2, 2016

Did a quick PoC and pre-compiling the regexp seems to help. The reason it was so bad was that we were compiling all defined regexps for each process present on the system. That can add up quite quickly.

The fix is quite simple, I'll open a PR with it.

@tsg
Copy link
Contributor

tsg commented May 2, 2016

I was too quick with the above. It seems more related with getting the command line (which is expensive on Windows) on every call when the processes don't match the regexp.

tsg pushed a commit to tsg/beats that referenced this issue May 4, 2016
This decouples getting the basic state information from getting the more
detailed information.  The reason is that filtering only needs the name, but
the code was getting all details and then apply filtering. Getting the command
line is expensive on Windows, so that contributed to elastic#1460.

What made it worse is that due to filtering, the command line cache was
invalidated on each run, which explains why topbeat was consuming more CPU when
filtering out processes than when not.

Fixes elastic#1460.

This also pre-compiles the regexps, which brings some slight CPU usage improvements
and uncovers compilation errors earlier.
ruflin pushed a commit that referenced this issue May 4, 2016
* Re-factor to fix high CPU usage on windows

This decouples getting the basic state information from getting the more
detailed information.  The reason is that filtering only needs the name, but
the code was getting all details and then apply filtering. Getting the command
line is expensive on Windows, so that contributed to #1460.

What made it worse is that due to filtering, the command line cache was
invalidated on each run, which explains why topbeat was consuming more CPU when
filtering out processes than when not.

Fixes #1460.

This also pre-compiles the regexps, which brings some slight CPU usage improvements
and uncovers compilation errors earlier.

* Added error check in Metricbeat
tsg added a commit to tsg/beats that referenced this issue May 9, 2016
* Re-factor to fix high CPU usage on windows

This decouples getting the basic state information from getting the more
detailed information.  The reason is that filtering only needs the name, but
the code was getting all details and then apply filtering. Getting the command
line is expensive on Windows, so that contributed to elastic#1460.

What made it worse is that due to filtering, the command line cache was
invalidated on each run, which explains why topbeat was consuming more CPU when
filtering out processes than when not.

Fixes elastic#1460.

This also pre-compiles the regexps, which brings some slight CPU usage improvements
and uncovers compilation errors earlier.
ruflin pushed a commit that referenced this issue May 10, 2016
This decouples getting the basic state information from getting the more
detailed information.  The reason is that filtering only needs the name, but
the code was getting all details and then apply filtering. Getting the command
line is expensive on Windows, so that contributed to #1460.

What made it worse is that due to filtering, the command line cache was
invalidated on each run, which explains why topbeat was consuming more CPU when
filtering out processes than when not.

Fixes #1460.

This also pre-compiles the regexps, which brings some slight CPU usage improvements
and uncovers compilation errors earlier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants