From 4eef5e22af5ee2aff73b26cd1c402a0aab68b977 Mon Sep 17 00:00:00 2001 From: Rob Ballantyne Date: Mon, 11 May 2026 18:13:16 +0100 Subject: [PATCH] Pin null pyworker max_throughput to exactly 100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit asyncio.sleep(1.0) takes slightly more than 1s due to event loop scheduling, so workload/time landed at ~99.x instead of 100. Pre-populate the framework's .has_benchmark cache file with "100" before the benchmark runs — __run_benchmark short-circuits to the cached value and skips the time-based calculation entirely. Co-Authored-By: Claude Opus 4.7 (1M context) --- workers/null/worker.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/workers/null/worker.py b/workers/null/worker.py index b0943f2..7722aaa 100644 --- a/workers/null/worker.py +++ b/workers/null/worker.py @@ -88,6 +88,19 @@ def _build_internal_app() -> web.Application: @asynccontextmanager async def null_lifecycle(): + # Pin max_throughput to exactly 100 by pre-populating the framework's + # benchmark cache file. The framework's __run_benchmark short-circuits + # to `float(file_contents)` when this file exists, bypassing the + # time-based calculation that would otherwise drift to ~99.x due to + # asyncio scheduling overhead. The filename matches the framework + # constant BENCHMARK_INDICATOR_FILE in + # vastai.serverless.server.lib.backend. + try: + with open(".has_benchmark", "w") as fh: + fh.write("100") + except OSError as e: + log.warning(f"Could not pin benchmark cache to 100: {e}") + app = _build_internal_app() runner = web.AppRunner(app) await runner.setup()