diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 18:06:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 18:06:39 +0300 |
commit | 97b63407ef0ecacc239fe320a9b87eefdebfe70c (patch) | |
tree | 64f9ab65e07bee7d37c1559e59e1607dc819cfe1 /lib/gitlab/chaos.rb | |
parent | a68e9d3318c6847436f81f83eb347b29f52d1bff (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/chaos.rb')
-rw-r--r-- | lib/gitlab/chaos.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/gitlab/chaos.rb b/lib/gitlab/chaos.rb index 4f47cdef971..911f2993b8a 100644 --- a/lib/gitlab/chaos.rb +++ b/lib/gitlab/chaos.rb @@ -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 |