-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Total Processes in MiscStat
Corrected
#1612
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The `ProcsTotal` in the `MiscStat` structure was very inaccurate. It was reading a value which is the total number of kernel scheduling entities. This includes both processes and threads significantly overcounting. This instead uses an existing method already in common to count the number of processes via the /proc filesystem where any directory is a number. This should still be a single syscall to read that directory entry. This fixes shirou#1606.
shirou
approved these changes
Mar 23, 2024
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.
Great work. Thank you so much!
dmitryax
referenced
this pull request
in open-telemetry/opentelemetry-collector
Apr 2, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/shirou/gopsutil/v3](https://togithub.com/shirou/gopsutil) | `v3.24.2` -> `v3.24.3` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fshirou%2fgopsutil%2fv3/v3.24.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fshirou%2fgopsutil%2fv3/v3.24.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fshirou%2fgopsutil%2fv3/v3.24.2/v3.24.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fshirou%2fgopsutil%2fv3/v3.24.2/v3.24.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>shirou/gopsutil (github.com/shirou/gopsutil/v3)</summary> ### [`v3.24.3`](https://togithub.com/shirou/gopsutil/releases/tag/v3.24.3) [Compare Source](https://togithub.com/shirou/gopsutil/compare/v3.24.2...v3.24.3) <!-- Release notes generated using configuration in .github/release.yml at v3.24.3 --> #### What's Changed ##### disk - chore: fix typo by [@​majorteach](https://togithub.com/majorteach) in [https://github.com/shirou/gopsutil/pull/1615](https://togithub.com/shirou/gopsutil/pull/1615) ##### host - \[host]\[linux]: fix utmp size on linux/arm64 by [@​shirou](https://togithub.com/shirou) in [https://github.com/shirou/gopsutil/pull/1603](https://togithub.com/shirou/gopsutil/pull/1603) ##### load - Total Processes in `MiscStat` Corrected by [@​eric1234](https://togithub.com/eric1234) in [https://github.com/shirou/gopsutil/pull/1612](https://togithub.com/shirou/gopsutil/pull/1612) ##### process - \[process]\[freebsd]: re-generate types on freebsd arm64 by [@​shirou](https://togithub.com/shirou) in [https://github.com/shirou/gopsutil/pull/1609](https://togithub.com/shirou/gopsutil/pull/1609) #### New Contributors - [@​majorteach](https://togithub.com/majorteach) made their first contribution in [https://github.com/shirou/gopsutil/pull/1615](https://togithub.com/shirou/gopsutil/pull/1615) - [@​eric1234](https://togithub.com/eric1234) made their first contribution in [https://github.com/shirou/gopsutil/pull/1612](https://togithub.com/shirou/gopsutil/pull/1612) **Full Changelog**: shirou/gopsutil@v3.24.2...v3.24.3 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <[email protected]>
mx-psi
referenced
this pull request
in open-telemetry/opentelemetry-collector-contrib
Apr 2, 2024
…2096) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/shirou/gopsutil/v3](https://togithub.com/shirou/gopsutil) | `v3.24.2` -> `v3.24.3` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fshirou%2fgopsutil%2fv3/v3.24.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fshirou%2fgopsutil%2fv3/v3.24.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fshirou%2fgopsutil%2fv3/v3.24.2/v3.24.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fshirou%2fgopsutil%2fv3/v3.24.2/v3.24.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>shirou/gopsutil (github.com/shirou/gopsutil/v3)</summary> ### [`v3.24.3`](https://togithub.com/shirou/gopsutil/releases/tag/v3.24.3) [Compare Source](https://togithub.com/shirou/gopsutil/compare/v3.24.2...v3.24.3) <!-- Release notes generated using configuration in .github/release.yml at v3.24.3 --> #### What's Changed ##### disk - chore: fix typo by [@​majorteach](https://togithub.com/majorteach) in [https://github.com/shirou/gopsutil/pull/1615](https://togithub.com/shirou/gopsutil/pull/1615) ##### host - \[host]\[linux]: fix utmp size on linux/arm64 by [@​shirou](https://togithub.com/shirou) in [https://github.com/shirou/gopsutil/pull/1603](https://togithub.com/shirou/gopsutil/pull/1603) ##### load - Total Processes in `MiscStat` Corrected by [@​eric1234](https://togithub.com/eric1234) in [https://github.com/shirou/gopsutil/pull/1612](https://togithub.com/shirou/gopsutil/pull/1612) ##### process - \[process]\[freebsd]: re-generate types on freebsd arm64 by [@​shirou](https://togithub.com/shirou) in [https://github.com/shirou/gopsutil/pull/1609](https://togithub.com/shirou/gopsutil/pull/1609) #### New Contributors - [@​majorteach](https://togithub.com/majorteach) made their first contribution in [https://github.com/shirou/gopsutil/pull/1615](https://togithub.com/shirou/gopsutil/pull/1615) - [@​eric1234](https://togithub.com/eric1234) made their first contribution in [https://github.com/shirou/gopsutil/pull/1612](https://togithub.com/shirou/gopsutil/pull/1612) **Full Changelog**: shirou/gopsutil@v3.24.2...v3.24.3 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
ProcsTotal
in theMiscStat
structure was very inaccurate. It was reading a value which is the total number of kernel scheduling entities. This includes both processes and threads significantly overcounting.This instead uses an existing method already in common to count the number of processes via the /proc filesystem where any directory is a number. This should still be a single syscall to read that directory entry.
I don't see any existing automated test with this functionality so I did not add any but I did do my own manual testing by writing the following program:
With the previous code it was returning a value of over 1200. After the change the count was around 320 and matched
ps -A | wc -l
.This fixes #1606.