You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, the running time of processes on macOS is not updated correctly. I made two commit to try to fix this problem. The branch is rebased on the PR #1617.
Summary:
Removed the call to Platform_machTicksToNanoseconds. The proc_taskinfo structure contains the running time (both system and user) of the process. We should just take those value in nanoseconds and convert them in the proper unit. How the kernel handles this calculation (starting from low level cpu-dependent details) should not concern us.
I also removed the static function nanosecondsToCentiseconds because for some reason we lose precision (± 1ms) with that calculation. If we divide directly by 1e7, we get a more precise measure. Probably it's a good idea to have an inline function or (maybe better) a macro, just to give a name to that operation and avoid the magic number;
Since the GPU percentage update depends on the running time of the process, I updated the condition in the if statement. In fact, suppose we are at the nth iteration of the DarwinProcess_setFromLibprocPidinfo function. We should update the CPU usage value if the total CPU running time of the process is greater than the CPU running time of the process in the previous iteration. To do that, we do not need to use the timeIntervalNS.
TODO:
remove the static double Platform_nanosecondsPerMachTick var in Darwin/Platform.c as well. It's only used in the (removed) Platform_machTicksToNanoseconds.
remove the Platform_calculateNanosecondsPerMachTick function in Darwin/PlatformHelpers.c. It's only used to set the static double Platform_nanosecondsPerMachTick var once.
I attach here 3 sshot. The first one is the current version (3.3.0), the second one is the darwin-running-time brach, and the last one is top.
3.3.0:
darwin-running-time:
top:
The text was updated successfully, but these errors were encountered:
At the moment, the running time of processes on macOS is not updated correctly. I made two commit to try to fix this problem. The branch is rebased on the PR #1617.
Summary:
Platform_machTicksToNanoseconds
. Theproc_taskinfo
structure contains the running time (both system and user) of the process. We should just take those value in nanoseconds and convert them in the proper unit. How the kernel handles this calculation (starting from low level cpu-dependent details) should not concern us.nanosecondsToCentiseconds
because for some reason we lose precision (± 1ms) with that calculation. If we divide directly by 1e7, we get a more precise measure. Probably it's a good idea to have an inline function or (maybe better) a macro, just to give a name to that operation and avoid the magic number;DarwinProcess_setFromLibprocPidinfo
function. We should update the CPU usage value if the total CPU running time of the process is greater than the CPU running time of the process in the previous iteration. To do that, we do not need to use thetimeIntervalNS
.TODO:
static double Platform_nanosecondsPerMachTick
var inDarwin/Platform.c
as well. It's only used in the (removed)Platform_machTicksToNanoseconds
.Platform_calculateNanosecondsPerMachTick
function inDarwin/PlatformHelpers.c
. It's only used to set thestatic double Platform_nanosecondsPerMachTick
var once.I attach here 3 sshot. The first one is the current version (3.3.0), the second one is the
darwin-running-time
brach, and the last one is top.darwin-running-time
:The text was updated successfully, but these errors were encountered: