-
-
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
Saving boot time during ProcessesWithContext call (linux). #1497
Conversation
Simple benchmark (just calling before:
with change:
(depends heavily on the number of processes running) |
On Linux, the system boot time is used when calculating process creation times (expressed as number of seconds since the epoch). Obtaining the boot time involves parsing the /proc/stat file, which can incur siginificant overhead on systems with many CPU cores. Permanently caching the boot time is not an option since it can change when the system clock is updated (e.g. ntpd). In this changeset we will save the boot time during one invocation of the ProcessesWithContext function (listing all running processes).
51102f8
to
d9aa16a
Compare
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.
Thanks for the PR. However, putting boot time information into the context is difficult to be accepted as an OSS library.
We request that putting the value in the context be handled by the user of gopsutil.
and also, #1283 is related.
Requested changes have been implemented. |
Ah, I am sorry that I have misled you. What I meant was that caching in context should be done by the Application that uses gopsutil, not in the gopsutil, because it is a Library. To use a different term, we are unable to accept this PR. |
@shirou I don't understand -- caching is done by the application, the library only uses the cached value when available. |
We do not want to add more context values. And also, bootTime can jump if time gets adjusted, described in this comment. |
On Linux, the system boot time is used when calculating process creation times (expressed as number of seconds since the epoch). Obtaining the boot time involves parsing the /proc/stat file, which can incur siginificant overhead on systems with many CPU cores.
Permanently caching the boot time is not an option since it can change when the system clock is updated (e.g. ntpd).
In this changeset we will save the boot time during one invocation of the ProcessesWithContext function (listing all running processes).