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

[core][wmi] new WMI metric collection core #2011

Merged
merged 3 commits into from
Nov 3, 2015

Conversation

yannmh
Copy link
Member

@yannmh yannmh commented Oct 28, 2015

Original discussion thread: #1952
Credits to @TheCloudlessSky (https://github.com/TheCloudlessSky) . Thanks a lot !!!

WMI module + CounterType calculators

A lightweight Python WMI module wrapper built on top of pywin32 and
win32com extensions.

Specifications

  • Based on top of the pywin32 and win32com third party extensions only
  • Compatible with Raw* and Formatted Performance Data classes
    • Dynamically resolve properties' counter types
    • Hold the previous/current Raw samples to compute/format new values*
  • Fast and lightweight
    • Avoid queries overhead
    • Cache connections and qualifiers
    • Use wbemFlagForwardOnly flag to improve enumeration/memory performance

__ Raw data formatting relies on the avaibility of the corresponding calculator.
Please refer to checks.lib.wmi.counter_type for more information*

Windows system check speedup

Speedup the Windows system check:

  • Drop third party wmi Python package in favor of the local checks.lib.wmi module
  • Use PerfRawData WMI Performance classes rather than PerfFormattedData

WMI check speedup

Speedup the generic WMI check:

  • Drop third party wmi Python package in favor of the local checks.lib.wmi module

@yannmh yannmh self-assigned this Oct 28, 2015
@yannmh yannmh added this to the 5.6.0 milestone Oct 28, 2015
@yannmh yannmh changed the title [core][wmi] [core][wmi] WMI metric collection speedup Oct 28, 2015
@yannmh yannmh changed the title [core][wmi] WMI metric collection speedup [core][wmi] new WMI metric collection core Oct 28, 2015
@yannmh yannmh removed their assignment Oct 28, 2015
@remh
Copy link

remh commented Oct 28, 2015

Haven't reviewed it yet but really excited about this one!

@yannmh yannmh assigned yannmh and unassigned yannmh Oct 28, 2015
@TheCloudlessSky
Copy link

Awesome job @yannmh ⭐!

  1. Were you able to see similar performance improvements?
  2. Given that implementors of custom checks will be using this (I already have several WMI classes I'd want to use it with), should it be possible to pass unimplemented counter type calculators to the WMISampler? Ideally, they'd be contributed back to the dd-agent repository. But, I don't think manually maintaining the previous/current sample outside of the WMISampler is a good idea (the value from get_raw). Perhaps we could expose it by inheritance or a dictionary parameter?

Thanks again for moving forward with this!

A lightweight Python WMI module wrapper built on top of `pywin32` and
`win32com` extensions.

**Specifications**
* Based on top of the `pywin32` and `win32com` third party extensions
* only
* Compatible with `Raw`* and `Formatted` Performance Data classes
    * Dynamically resolve properties' counter types
    * Hold the previous/current `Raw` samples to compute/format new
    * values*
* Fast and lightweight
    * Avoid queries overhead
    * Cache connections and qualifiers
    * Use `wbemFlagForwardOnly` flag to improve enumeration/memory
    * performance

*\* `Raw` data formatting relies on the avaibility of the corresponding
calculator.
Please refer to `checks.lib.wmi.counter_type` for more information*

Original discussion thread:
#1952
Credits to @TheCloudlessSky (https://github.com/TheCloudlessSky)
"""
Speedup the Windows system check:
* Drop third party `wmi` Python package in favor of the local
  `checks.lib.wmi` module
* Use `PerfRawData` WMI Performance classes rather than
 `PerfFormattedData`
Speedup the Windows system check:
* Drop third party `wmi` Python package in favor of the local
  `checks.lib.wmi` module
@yannmh yannmh force-pushed the yann/wmi-new-collector branch from 41a1646 to 8bd9bb0 Compare November 3, 2015 00:59
@yannmh
Copy link
Member Author

yannmh commented Nov 3, 2015

@TheCloudlessSky,

Were you able to see similar performance improvements?

I built a custom Datadog Agent to benchmark those changes. It run both (old and new) system and WMI checks and add metrics to measure those checks' run times.

Results 🎺
I made a Datadog screen board to visualize the results.
screenshot 2015-11-03 11 58 33

To sum up:

  1. System check takes ~10 times less to run.
  2. WMI check takes between ~5 and ~10 time less to run depending on the class data type (RawData vs FormattedData). On my machine that's ~10 seconds less to collect ~2k WMI metrics.
  3. Collecting RawData vs FormattedData shows ~2 'gain' factor.

Overall the performance gain is as significant as it was advertised before !:tada: :confetti_ball: :balloon:

Given that implementors of custom checks will be using this (I already have several WMI classes I'd want to use it with), should it be possible to pass unimplemented counter type calculators to the WMISampler? Ideally, they'd be contributed back to the dd-agent repository. But, I don't think manually maintaining the previous/current sample outside of the WMISampler is a good idea (the value from get_raw). Perhaps we could expose it by inheritance or a dictionary parameter?

Thanks for the suggestion. I agree, I think it would be a nice feature to have.
We'll work on it on a separate PR and keep you informed about it !

@olivielpeau
Copy link
Member

Looking pretty awesome, let's :shipit: !

olivielpeau added a commit that referenced this pull request Nov 3, 2015
[core][wmi] new WMI metric collection core
@olivielpeau olivielpeau merged commit d062183 into master Nov 3, 2015
@olivielpeau olivielpeau deleted the yann/wmi-new-collector branch November 3, 2015 17:32
@TheCloudlessSky
Copy link

Awesome @yannmh! I'm super excited about these changes landing in 5.6.0! 🎉 !

@irabinovitch
Copy link
Contributor

@TheCloudlessSky Thank you for your excellent work on this refactor. Can you shoot me a note with your contact info via email? (ilan at datadoghq.com). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants