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

feature update #5

Merged
merged 5 commits into from
Sep 9, 2024
Merged

feature update #5

merged 5 commits into from
Sep 9, 2024

Conversation

komar007
Copy link
Owner

@komar007 komar007 commented Sep 9, 2024

No description provided.

All the daemon creation/connection abstraction was extracted as a
separate crate with_daemon and pidtree_mon now uses it as a dependency.
The previous algorithm would perfrom a measurement by collecting 2
samples of data from /proc some 100ms apart and comparing ticks used by
various processes between the 2 samples, then cumulating the results
over process trees. This didn't work very well for cases when the
monitored processes spawned a lot of child processes that exited
quickly, because:
 - about 90% of the information was lost during the wait - the reason a
   100 ms interval was chosen in the first place was to lose as little
   information about spawned and killed processes as possible, while not
   having to update too frequently, but that meant an averaging window
   of 100ms, only once every 1000ms.
 - still, processes that both appeared and disappeared between 2
   measurement points would get neglected, and so would the ticks
   consumed by processes that disappeared between measurements between
   the last measurement and the time the process disappeared.

The new algorithm finally seems to account for all previously known
problems, which was tested by comparing the output to the output of
top/htop showing full CPU load when nothing much was running on the PC
except for the measured process trees.
Now we are retrieving the time since boot in ticks instead of adding up
ticks elapsed on all CPUs. This seems to have only one disadvantage:
when running in a VM, this will not account for the time stolen by the
host, so the calculated loads will be in relation to the one physical
core, instead of one virtual core.

At some point we might need a user option to control this behavior. Then
we'll re-add the tick-counting code.
@komar007 komar007 merged commit 84b7f25 into main Sep 9, 2024
5 checks passed
@komar007 komar007 deleted the update branch September 9, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant