Negative value shown for min_response_time:

0 or positive value.
Negative value shown for min_response_time
I have a branch local docker-compose setup to reproduce it easily. But it's just 1 worker calling nginx in another docker container.
This line is returning a negative value: https://github.com/locustio/locust/blob/b18cf1e96646a4d43dc16f9d80e435c8f1596a33/locust/clients.py#L117
Perhaps a docker clock source issue 🤔
Docker itself just using the host clock source but docker on Mac (what I'm using) uses HyperKit VM as Mac kernel doesn't support native docker. Perhaps this VM clock source is not reliable?
There's lots of docker clock issues but as far as I can see they are related to sleep: https://github.com/moby/hyperkit/issues/110
If it was a docker issue, it would be easy to reproduce outside of locust with a file like this:
import time
while True:
t = time.time()
if time.time() < t:
print('ERROR: {0} is less than {1}'.format(time.time(), t))
break
And then run it like docker run -v $PWD:/mnt python:latest python /mnt/time_test.py
Ah, after leaving this for a while I get an error 😅
ERROR: 1595435189.4236984 is less than 1595435189.4583442
OK, good to know!
Should we make a change to the locust code though? Like to record the response time as 0 in this case?
Can you try replacing the two calls to time.time() with time.monotonic()?
I thought we did that a long time ago, but maybe it was only done for FastHttpUser or something.
Interesting.
Should we make a change to the locust code though? Like to record the response time as 0 in this case?
I don't think we should "hide" the clock issue by setting it to zero if it's negative.
I don't think we should "hide" the clock issue by setting it to zero if it's negative.
Makes sense
Can you try replacing the two calls to time.time() with time.monotonic()?
This solves it for me. Both in docker without locust and in my locust test.
Shall I make a PR to switch any time measurement to use time.monotonic()? We should probably be using this anyway as even without docker the main clock on any host can go backwards (with NTP, chrony etc) anyway
Please do!
Most helpful comment
Interesting.
I don't think we should "hide" the clock issue by setting it to zero if it's negative.