diff options
author | Erwan Velu <erwan@redhat.com> | 2018-06-07 15:56:45 +0200 |
---|---|---|
committer | Erwan Velu <erwan@redhat.com> | 2018-06-25 22:09:14 +0200 |
commit | 7b0d1c8b8acff2a7010bfb0400df09786033ac63 (patch) | |
tree | 4c560692aa93709e5c7154c436202769216d114c /qa/standalone | |
parent | Merge PR #22626 into master (diff) | |
download | ceph-7b0d1c8b8acff2a7010bfb0400df09786033ac63.tar.xz ceph-7b0d1c8b8acff2a7010bfb0400df09786033ac63.zip |
qa/standalone/ceph-helpers.sh: Thinner resolution in get_timeout_delays()
get_timeout_delays() is a generic function to compute delays for a long
period of time without saturating the CPU is busy loops.
It works pretty fine when the delay is short like having the following
series when requesting a 20seconds timeout : "0.1 0.2 0.4 0.8 1.6 3.2 6.4 7.3 ".
Here the maximum between two loops is 7.3 which is perfectly fine.
When the timeout reaches 300sec, the same code produces the following
series : "0.1 0.2 0.4 0.8 1.6 3.2 6.4 12.8 25.6 51.2 102.4 95.3 "
In such example there is delays which are nearly 2 minutes !
That is not efficient as the expected event, between two loops, could
arrive just after this long sleep occurs making a minute+ sleep for
nothing. On a local system that could be ok while on a CI, if all jobs
run like CI the overall is pretty unefficient by generating useless CPU
waits.
This patch is about adding a maximum acceptable delay time between two
loops while keeping the same rampup behavior.
On the same 300 seconds delay example, with MAX_TIMEOUT set to 10, we
now have the following series: "0.1 0.2 0.4 0.8 1.6 3.2 6.4 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 7.3"
We can see that the long 12/25/51/102/95 values vanished and being
replaced by a series of 10 seconds. It's up to every test defining the
probability of having a soonish event to complete.
The MAX_TIMEOUT is set to 15seconds.
Signed-off-by: Erwan Velu <erwan@redhat.com>
Diffstat (limited to 'qa/standalone')
-rwxr-xr-x | qa/standalone/ceph-helpers.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/qa/standalone/ceph-helpers.sh b/qa/standalone/ceph-helpers.sh index 2cae98bc5ff..ef505873757 100755 --- a/qa/standalone/ceph-helpers.sh +++ b/qa/standalone/ceph-helpers.sh @@ -19,6 +19,7 @@ # TIMEOUT=300 WAIT_FOR_CLEAN_TIMEOUT=90 +MAX_TIMEOUT=15 PG_NUM=4 CEPH_BUILD_VIRTUALENV=${TMPDIR:-/tmp} @@ -1408,6 +1409,7 @@ function get_timeout_delays() { $trace && shopt -u -o xtrace local timeout=$1 local first_step=${2:-1} + local max_timeout=${3:-$MAX_TIMEOUT} local i local total="0" @@ -1416,6 +1418,13 @@ function get_timeout_delays() { echo -n "$(calc $i) " total=$(calc $total + $i) i=$(calc $i \* 2) + if [ $max_timeout -gt 0 ]; then + # Did we reach max timeout ? + if [ ${i%.*} -eq ${max_timeout%.*} ] && [ ${i#*.} \> ${max_timeout#*.} ] || [ ${i%.*} -gt ${max_timeout%.*} ]; then + # Yes, so let's cap the max wait time to max + i=$max_timeout + fi + fi done if test "$(calc $total \< $timeout)" = "1"; then echo -n "$(calc $timeout - $total) " @@ -1435,6 +1444,8 @@ function test_get_timeout_delays() { test "$(get_timeout_delays 6 .1)" = "0.1 0.2 0.4 0.8 1.6 2.9 " || return 1 test "$(get_timeout_delays 6.3 .1)" = "0.1 0.2 0.4 0.8 1.6 3.2 " || return 1 test "$(get_timeout_delays 20 .1)" = "0.1 0.2 0.4 0.8 1.6 3.2 6.4 7.3 " || return 1 + test "$(get_timeout_delays 300 .1)" = "0.1 0.2 0.4 0.8 1.6 3.2 6.4 12.8 25.6 51.2 102.4 95.3 " || return 1 + test "$(get_timeout_delays 300 .1 10)" = "0.1 0.2 0.4 0.8 1.6 3.2 6.4 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 7.3" || return 1 } ####################################################################### |