-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conversation
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Windows and OS X, looks good and the CPU usage dropped significantly 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 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. |
LGTM. Waiting for Travis... |
Merging without Travis as Travis seems to be stuck ... |
* 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.
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.
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.