Skip to content

Fix Sidekiq job total CPU time

Qingyu Zhao requested to merge fix-sidekiq-job-total-cpu-time into master

What does this MR do?

Implement issue #31887 (closed)

The issue description has clearly described the issue and proposed solution.

We merged the https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31866.

However, this is not working as expected as we are using Process.times that accounts
all CPU time from all threads. This results in wrong results returned and attached
to each structured_logging.

We really want to use getrusage(RUSAGE_THREAD). This is not currently exported by Ruby which means that we should write native extension to add this.
For time being it seems that we cannot show system_s and child_s, but we can show user_s(should this be `user_s + system_s`?) with usage of:
Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID)
Edited by 🤖 GitLab Bot 🤖

Merge request reports