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

adding use_oneshot parameter to speed up check runs with psutil.Process().oneshot() #17817

Merged
merged 8 commits into from
Jun 21, 2024

Conversation

mrafi97
Copy link
Contributor

@mrafi97 mrafi97 commented Jun 12, 2024

What does this PR do?

This check adds a bool parameter use_oneshot that can be set to true so that the check uses psutil.Process().oneshot() (https://psutil.readthedocs.io/en/latest/#psutil.Process.oneshot) to cache metrics and have a ~2x speed up of the check run.

This defaults to true so that users are using the quicker/more efficient version of the check.

Motivation

https://datadoghq.atlassian.net/browse/WINA-805

Additional Notes

From psutil docs: https://psutil.readthedocs.io/en/latest/#psutil.Process.oneshot

The advice is to use this every time you retrieve more than one information about the process.

With this in mind we have set use_oneshot to be true by default since the check runs the psutil.Process methods often. So far this was tested through ddev on a Windows Laptop and a Linux container.

Benchmark results:
image

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Changelog entries must be created for modifications to shipped code
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Copy link

The validations job has failed; please review the Files changed tab for possible suggestions to resolve.

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 96.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.92%. Comparing base (32b11da) to head (6bb8ac3).
Report is 59 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
activemq ?
cassandra ?
hive ?
hivemq ?
ignite ?
jboss_wildfly ?
kafka ?
presto ?
process 85.61% <96.66%> (+0.61%) ⬆️
solr ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link

The validations job has failed; please review the Files changed tab for possible suggestions to resolve.

process/tests/test_process.py Outdated Show resolved Hide resolved
process/tests/test_process.py Outdated Show resolved Hide resolved
Copy link

The validations job has failed; please review the Files changed tab for possible suggestions to resolve.

Copy link

The validations job has failed; please review the Files changed tab for possible suggestions to resolve.

2 similar comments
Copy link

The validations job has failed; please review the Files changed tab for possible suggestions to resolve.

Copy link

The validations job has failed; please review the Files changed tab for possible suggestions to resolve.

Co-authored-by: Steven Yuen <steven.yuen@datadoghq.com>
@mrafi97 mrafi97 requested a review from a team June 14, 2024 20:16
clarkb7
clarkb7 previously approved these changes Jun 14, 2024
Kyle-Neale
Kyle-Neale previously approved these changes Jun 15, 2024
Co-authored-by: Kyle Neale <kyle.neale@datadoghq.com>
@clarkb7 clarkb7 dismissed stale reviews from Kyle-Neale and themself via 6bb8ac3 June 21, 2024 16:59
@clarkb7 clarkb7 merged commit 8cf3d23 into master Jun 21, 2024
37 checks passed
@clarkb7 clarkb7 deleted the mrafi/process_oneshot branch June 21, 2024 17:12
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.

4 participants