Commit db9f2c3e authored by Kamil Trzciński's avatar Kamil Trzciński

Make `Chaos.cpu_spin` to consume thread

This changes `.cpu_spin` to actually
consume thread for the desired duration,
by looking at CPU thread time.
parent b06f28e6
......@@ -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