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

Re-factor to fix high CPU usage on windows #1562

Merged
merged 2 commits into from
May 4, 2016

Conversation

tsg
Copy link
Contributor

@tsg tsg commented May 3, 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.

@tsg
Copy link
Contributor Author

tsg commented May 3, 2016

Don't merge yet, please, I need to test if it all looks good under Windows.

@@ -115,7 +115,10 @@ func (t *Topbeat) Setup(b *beat.Beat) error {
func (t *Topbeat) Run(b *beat.Beat) error {
var err error

t.procStats.InitProcStats()
err = t.procStats.InitProcStats()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ruflin this might conflict with #1081, let's see which PR gets merged first so we can updated the other.

@tsg tsg force-pushed the fix_topbeat_high_cpu branch from 289f25a to d2afe96 Compare May 3, 2016 20:52
@tsg
Copy link
Contributor Author

tsg commented May 3, 2016

Tested on Windows and OS X, looks good and the CPU usage dropped significantly on Windows.

@ruflin
Copy link
Collaborator

ruflin commented May 4, 2016

@tsg #1081 and #1566 were both merged with changes in topbeat. Rebase on top of it probably makes sense even though there does not seem to be a conflict. make fmt and one topbeat test seem to be failing.

@tsg tsg force-pushed the fix_topbeat_high_cpu branch from d2afe96 to 8010d05 Compare May 4, 2016 07:37
Tudor Golubenco added 2 commits May 4, 2016 09:38
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.
@tsg tsg force-pushed the fix_topbeat_high_cpu branch from 8010d05 to 86c3a65 Compare May 4, 2016 07:42
@tsg
Copy link
Contributor Author

tsg commented May 4, 2016

@ruflin there was one slight change in the API (InitProcesses now can return an error). I rebased and added a commit to add the error check to Metricbeat. Please have a look.

The test and go vet should also be fixed now.

@ruflin
Copy link
Collaborator

ruflin commented May 4, 2016

LGTM. Waiting for Travis...

@ruflin
Copy link
Collaborator

ruflin commented May 4, 2016

Merging without Travis as Travis seems to be stuck ...

@ruflin ruflin merged commit c525d7e into elastic:master May 4, 2016
@tsg tsg added the needs_backport PR is waiting to be backported to other branches. label May 9, 2016
tsg added a commit to tsg/beats that referenced this pull request 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 pull request 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.
@tsg tsg removed the needs_backport PR is waiting to be backported to other branches. label Aug 1, 2016
@tsg tsg deleted the fix_topbeat_high_cpu branch August 25, 2016 10:34
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

Successfully merging this pull request may close these issues.

3 participants