Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use incremental backoff instead of hardcoding fixed sleep times #340

Merged

Conversation

omajid
Copy link
Member

@omajid omajid commented Feb 7, 2024

With fixed/long sleep times, tests run slower when there is no need to wait for that long. When the machine is slow (or under heavy load), we often to need to wait for longer before things are running and the fixed sleep times are not sufficient.

@omajid omajid force-pushed the backoff-instead-of-constant-sleep branch from fca4f9b to b7de427 Compare February 7, 2024 14:26
max_retries=20
until "$@"; do
((i+=1))
if [[ $i == "$max_retries" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we start printing messages as soon as something takes longer than 10 seconds, to give some additional visibility to things that are slow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

echo "$@" "still failing after $max_retries retries"
exit 1
fi
sleep $i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to move the sleep before the first attempt so we're giving some cpu time to what we're willing to wait for here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

set -x

i=0
max_retries=20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With max_retries 20, we're going from 5 seconds to about 200s. That's x 40.
max_retries 10 brings us to about 50s. x 10 seems plenty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Done.


set -euo pipefail

set -x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should leave this out to avoid more output in the test, and let this helper print useful messages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@tmds tmds requested a review from nicrowe00 February 14, 2024 07:04
@omajid omajid force-pushed the backoff-instead-of-constant-sleep branch from b7de427 to e15c0c2 Compare February 26, 2024 19:41
With fixed/long sleep times, tests run slower when there is no need to
wait for that long. When the machine is slow (or under heavy load), we
often to need to wait for longer before things are running and the fixed
sleep times are not sufficient.
@omajid omajid force-pushed the backoff-instead-of-constant-sleep branch from e15c0c2 to d8af8e8 Compare March 5, 2024 23:27
@omajid
Copy link
Member Author

omajid commented Mar 6, 2024

I am merging this because the insufficient-sleep issue is making it much more difficult to get passing tests for me. If there are any outstanding concerns with this PR, please let me know and we can work through them in a separate PR. TIA.

@omajid omajid merged commit eedd88e into redhat-developer:main Mar 6, 2024
23 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants