docs(docker-tests): document why poll loop beats blocking exec in wait_for_container_ready

Tried replacing the N-times-docker-exec polling loop with a single
blocking docker exec (in-container until/sleep loop). CI profiling
showed this was a net regression: docker exec connection overhead on
shared runners is ~0.7-1s per call, while the existing poll approach
uses 3-7 quick 0.27s execs. The blocking approach traded fewer calls
for longer per-call duration and lost.

Reverted to the original poll loop, added a docstring note explaining
why so the next person does not re-attempt the same optimization.
This commit is contained in:
ethernet 2026-07-14 15:44:55 -04:00
parent 3e89edf830
commit ca6ede33e1

View file

@ -195,6 +195,14 @@ def wait_for_container_ready(
Raises ``TimeoutError`` if the container never becomes ready — much
better than a fixed ``time.sleep()`` that either wastes time on fast
machines or flakes on slow ones.
Note: an earlier iteration tried a single blocking ``docker exec``
with an in-container ``until`` loop to eliminate polling overhead.
That was a net regression on CI: the per-``docker exec`` connection
overhead on shared runners (~0.7–1s) is higher than the cost of
3–7 quick poll calls (0.27s each), so the blocking approach traded
fewer calls for longer per-call duration and lost. The poll loop
is kept because it's better suited to CI's docker exec cost profile.
"""
end = time.monotonic() + deadline_s
while time.monotonic() < end: