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
* Account for CPU used by child processes
getCpuAndContexts() only sampled RUSAGE_SELF, so CPU burned by forked
children was never reported. Sample RUSAGE_CHILDREN as well.
The final measurement is reachable via finalizeProcessMonitoring()
instead of only ~Monitoring(), and bypasses the 1s rate guard, which
would otherwise discard a delta that no later call can pick up.
Details:
* RUSAGE_CHILDREN only becomes non-zero once a child has been reaped, so
this is one half of the fix: the caller has to reap the child, and has
to do so without killing an intermediate shell first. See the
companion change in AliceO2Group/AliceO2#15636.
* Forced (final) measurements are deliberately excluded from the
percentage series. A reaped child's CPU becomes visible as one lump,
and lump / (time since the last sample) is a meaningless rate - 14315%
was observed before this exclusion. Only the absolute and accumulated
fields carry meaning for such a sample, so consumers that care about
external subprocesses (Hyperloop accounting) should read
cpuTimeConsumedByProcess, not the percentage series.
* Consequently a process that ends before the first periodic sample has
no percentage at all - pushLoop() sleeps 100ms before sampling - and
averaging over the empty series produced a NaN averageCpuUsedPercentage.
Verified with a Monitoring instance destroyed after 10ms: 'nan' before,
'0.14' on the unpatched library. Such a measurement now reports no
average instead of a NaN one.
* init() clears the aggregates, so monitoring that is stopped and started
again reports the new period rather than blending it with the previous
one. DPL devices go RUNNING -> READY -> RUNNING across runs and re-arm
process monitoring on start.
Related to https://its.cern.ch/jira/browse/O2-7096
Assisted by Claude Opus 5
* Account for children in the context switches too
The previous commit made the CPU numbers the sum over this process and its
reaped children, but left the two context-switch counts on RUSAGE_SELF alone,
so a single measurement mixed a process-tree quantity with a parent-only one.
Both counts now sum the same pair of snapshots. Raised in review.
The surrounding measurement code is tidied while we are here: the CPU delta is
expressed in the same shape as the context-switch deltas, and the percentage is
computed only on the path that actually reports one.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments