-
-
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
ProcTotal Inaccurate in MiscStats
#1606
Comments
As I understand it, your argument is as follows. The After reading I will try to find a better way, but if you know of any, I would appreciate it if you could let me know. Thank you. |
I don't think so. I also searched through the man page as well as did some general web searches and the general consensus is to count OpenTelemetry expressed concern about this strategy being accurate due to changing processes while the count is going on. This initially made me think this wasn't a viable strategy. But it's also trying to collect status information on the pids as it's going. If we are just trying to get a process count then it's really just the one call to I would be open to putting together a PR that refactors |
Great to hear that! There does not seem to be a way to get the exact value in the proc file system, using I think it would be better to move |
Set down to implement this and it looks like there is already a different method in I'm going to work on making |
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.
Describe the bug
PR #682 added the ability to get the total number of processes via the
MiscStats
struct. It gets this information by reading the/proc/loadavg
file which looks like:The proc man page describes that file as:
The bolded text is the key part. In my example above, it's showing 1095 as the total number of kernel scheduled entities. But note it uses that term instead of "processes". It even indicates in parentheses that "kernel scheduled entities" is both processes and threads. But by the name
ProcTotal
and the fact that all other numbers inMiscStat
are processes only (not threads) this is implying I have 1095 processes when I do not. Thread count varies greatly. If I run it just a few minutes later it's showing 1127:Also if we actually count the processes in my system we find we only have a bit over 300:
Expected behavior
I would expect
ProcsTotal
to return the total number of processes not processes and threads. I don't know if there is something else that can be read in/proc
that gives just the total number of processes (I couldn't find anything) or if the attribute needs to be deprecated and removed for being in-accurate.I came across this due to OpenTelemtry using this struct to help measure the number of processes in the system and getting wildly high numbers. It actually calculates this number itself by reading all directories under
/proc
that are number. But then it only uses that as a starting place and offsets it with what this struct is providing saying:Based on that I don't think the OpenTelemetry strategy will be sufficient to get an accurate process count.
Environment (please complete the following information):
/etc/os-release
and the result ofuname -a
]$ uname -a Linux personal 6.6.10-76060610-generic #202401051437~1704728131~22.04~24d69e2 SMP PREEMPT_DYNAMIC Mon J x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: