From a7c778e3ba63cb4ce477e21f494292a152f6b2d6 Mon Sep 17 00:00:00 2001 From: ethernet Date: Tue, 14 Jul 2026 17:38:18 -0400 Subject: [PATCH] perf(docker-tests): halve poll intervals from 0.5s to 0.25s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reduce the default interval_s in poll_container, wait_for_docker_logs, and inline time.sleep() calls in test_dashboard.py and test_gateway_run_supervised.py from 0.5s to 0.25s. CI profile with sleep tracking showed 116.2s of time.sleep() across 345 sleep calls — 23% of total wall time. The majority of these sleeps were in poll_container (0.5s default) and inline polling loops in the dashboard and gateway-supervised tests. Halving the interval halves the sleep time for each poll cycle without changing docker call count or overhead. Unlike the blocking-exec experiment (which traded fewer calls for longer per-call duration and regressed on CI), this change only reduces idle sleep time — the docker exec calls stay the same. --- tests/docker/conftest.py | 4 ++-- tests/docker/test_dashboard.py | 6 +++--- tests/docker/test_gateway_run_supervised.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/docker/conftest.py b/tests/docker/conftest.py index 18e1f7bc2c2f..bef20f2e48ea 100644 --- a/tests/docker/conftest.py +++ b/tests/docker/conftest.py @@ -276,7 +276,7 @@ def poll_container( probe: str, *, deadline_s: float = 30.0, - interval_s: float = 0.5, + interval_s: float = 0.25, user: str = "hermes", ) -> tuple[bool, str]: """Repeatedly run ``probe`` inside the container until it exits 0 or @@ -343,7 +343,7 @@ def wait_for_log( def wait_for_docker_logs( - container: str, needle: str, *, deadline_s: float = 30.0, interval_s: float = 0.5, + container: str, needle: str, *, deadline_s: float = 30.0, interval_s: float = 0.25, ) -> str: """Poll ``docker logs`` until ``needle`` appears or deadline expires. diff --git a/tests/docker/test_dashboard.py b/tests/docker/test_dashboard.py index 911707c92621..964dd375f7f7 100644 --- a/tests/docker/test_dashboard.py +++ b/tests/docker/test_dashboard.py @@ -165,7 +165,7 @@ def test_dashboard_restarts_after_crash( if first_pids: first_pid = first_pids[0] break - time.sleep(0.5) + time.sleep(0.25) assert first_pid is not None, "Could not capture initial dashboard PID" # Kill the dashboard. The dashboard process runs as hermes, so the @@ -180,7 +180,7 @@ def test_dashboard_restarts_after_crash( pids = r.stdout.strip().split() if r.returncode == 0 else [] if pids and pids[0] != first_pid: return # success - time.sleep(0.5) + time.sleep(0.25) raise AssertionError( f"Dashboard not restarted after kill (first_pid={first_pid})" @@ -255,7 +255,7 @@ except urllib.error.HTTPError as h: last_err = f"parse: {exc!r} / stdout={r.stdout!r}" else: last_err = f"rc={r.returncode} stderr={r.stderr!r}" - time.sleep(0.5) + time.sleep(0.25) raise AssertionError( f"Probe of {path} never returned HTTP within {deadline_s}s; " f"last error: {last_err}" diff --git a/tests/docker/test_gateway_run_supervised.py b/tests/docker/test_gateway_run_supervised.py index 3e75c51db012..f7182f57ab95 100644 --- a/tests/docker/test_gateway_run_supervised.py +++ b/tests/docker/test_gateway_run_supervised.py @@ -79,7 +79,7 @@ def _wait_for_gateway_or_exit( ) if pgrep.returncode == 0: return "running" - time.sleep(0.5) + time.sleep(0.25) return status @@ -380,7 +380,7 @@ def test_dashboard_supervised_when_env_set( if _svstat_wants_up(container_name, "gateway-default"): ok_gateway = True break - time.sleep(0.5) + time.sleep(0.25) assert ok_gateway, ( f"gateway-default slot not want-up: {_svstat(container_name)!r}" ) @@ -391,7 +391,7 @@ def test_dashboard_supervised_when_env_set( if _svstat_wants_up(container_name, "dashboard"): ok_dash = True break - time.sleep(0.5) + time.sleep(0.25) assert ok_dash, ( f"dashboard slot not want-up: {_svstat(container_name, 'dashboard')!r}" )