Commit 8de65e70 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'make-cpu-spin-to-take-real-cpu' into 'master'

Make `Chaos.cpu_spin` to consume thread

See merge request gitlab-org/gitlab!20459
parents eb10fa5c db9f2c3e
......@@ -19,9 +19,11 @@ module Gitlab
# cpu_spin will consume all CPU on a single core for the specified duration
def self.cpu_spin(duration_s)
expected_end_time = Time.now + duration_s
return unless Gitlab::Metrics::System.thread_cpu_time
expected_end_time = Gitlab::Metrics::System.thread_cpu_time + duration_s
rand while Time.now < expected_end_time
rand while Gitlab::Metrics::System.thread_cpu_time < expected_end_time
end
# db_spin will query the database in a tight loop for the specified duration
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment