Skip to content

Commit e756216

Browse files
author
xiaoan17
committed
test(effect-runtime): measure the startup cost on this host
The Windows lane reports runtime_startup_timeout where the typed mutation_lock_timeout diagnostic is expected. The Python ready budget is 15s and the TypeScript mutation-lock budget is 5s; the missing number is what the runtime server actually costs to start on the host that runs the lane. The measurement lives in test_effect_runtime_integration.py because the Windows lane runs an explicit file list. CI runs pytest without -s, so the measurement is raised as a deliberate failure to make it readable from the job log. This file is a diagnostic, not a qualification. Signed-off-by: xiaoan17 <anbc1224@gmail.com>
1 parent 2f544f9 commit e756216

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

‎tests/control_plane/test_effect_runtime_integration.py‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,3 +2008,53 @@ def test_invalid_remote_error_envelope_fails_as_bounded_internal_error() -> None
20082008
assert isinstance(error, effect_runtime.EffectRuntimeInternalError)
20092009
assert error.diagnostic_code == "invalid_error_envelope"
20102010
assert "/private/path" not in str(error)
2011+
2012+
2013+
def test_measure_effect_runtime_startup_cost(tmp_path: Path) -> None:
2014+
"""Print the Effect runtime startup costs on this host (diagnostic).
2015+
2016+
The Windows lane reports `runtime_startup_timeout` where the typed
2017+
`mutation_lock_timeout` diagnostic is expected. The Python ready budget is
2018+
15s and the TypeScript mutation-lock budget is 5s; the missing number is
2019+
what the runtime server actually costs to start on the host that runs the
2020+
lane. This prints the measurements and never asserts, so it cannot fail a
2021+
lane.
2022+
"""
2023+
ready_dir = tmp_path / "ready"
2024+
ready_dir.mkdir(mode=0o700, parents=True)
2025+
effect_runtime._runtime_dir = lambda: ready_dir
2026+
start = time.monotonic()
2027+
effect_runtime.effect_runtime_result("runtime.ping", {}, retry_safe=False)
2028+
ready_seconds = time.monotonic() - start
2029+
2030+
locked_dir = tmp_path / "locked"
2031+
locked_dir.mkdir(mode=0o700, parents=True)
2032+
effect_runtime._runtime_dir = lambda: locked_dir
2033+
info_path = effect_runtime._runtime_info_path(effect_runtime._runtime_fingerprint())
2034+
Path(f"{info_path}.ts-effect.lock").write_text(
2035+
json.dumps({"pid": os.getpid(), "token": "startup-measurement-fixture"}),
2036+
encoding="utf-8",
2037+
)
2038+
start = time.monotonic()
2039+
try:
2040+
effect_runtime.effect_runtime_result("runtime.ping", {}, retry_safe=False)
2041+
code = "no-error"
2042+
except effect_runtime.EffectRuntimeStartupError as exc:
2043+
code = str(exc.diagnostic_code)
2044+
lock_seconds = time.monotonic() - start
2045+
line = (
2046+
"STARTUP_MEASURE platform=%r ready_seconds=%.3f live_lock_seconds=%.3f "
2047+
"live_lock_code=%r ready_budget=%r mutation_lock_budget=5.0"
2048+
% (
2049+
os.name,
2050+
ready_seconds,
2051+
lock_seconds,
2052+
code,
2053+
effect_runtime.STARTUP_READY_TIMEOUT_SECONDS,
2054+
)
2055+
)
2056+
# pytest runs without -s in CI, so stdout is captured and never shown.
2057+
# Fail deliberately with the measurement in the message so the number is
2058+
# readable from the job log. This file is a diagnostic, not a
2059+
# qualification.
2060+
raise AssertionError(line)

0 commit comments

Comments
 (0)