Fix ReportsDaemon `cpu_s`: measure thread time
What does this MR do and why?
We used Benchmark.measure
to measure cpu_s
here: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/memory/reports_daemon.rb.
It is not correct.
As pointed by @mkaeppler
:
Benchmark.measure
calls out to https://man7.org/linux/man-pages/man2/getrusage.2.html withRUSAGE_SELF
, which:
RUSAGE_SELF
Return resource usage statistics for the calling process,
which is the sum of resources used by all threads in the
process.
We should use, for example, Process::CLOCK_THREAD_CPUTIME_ID
instead.
You could find more in the thread: #367845 (comment 1042087332)
How to set up and validate locally
Similar to !91283 (merged)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #362900 (closed)
Edited by Aleksei Lipniagov