Use `cpu_perf_headroom()` for timing-test deadlines
`cpu_perf_headroom()` is a strict SUPERSET of `cpu_scaling_factor()` — it folds in static cpu-freq scaling + the slow-CI bump AND the sustained-load power-cap throttle probe. Point the timing-deadline call sites at it so they're robust to sustained throttling too (the gremlin behind mass `trio` deadline-miss flakes), - `test_legacy_one_way_streaming`: `time_quad_ex` cancel-deadline + `test_a_quadruple_example`'s `this_fast` smoke bound. - `test_cancellation`: `test_cancel_via_SIGINT_other_task` + `test_fast_graceful_cancel_*` deadlines. `cpu_perf_headroom >= cpu_scaling_factor` always, so never less headroom (CI stays green); `cpu_scaling_factor()` remains the internal static component. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codetest_cpu_throttling
parent
0ad5261905
commit
707caf63d1
|
|
@ -788,7 +788,7 @@ def test_cancel_via_SIGINT_other_task(
|
|||
started from a seperate ``trio`` child task.
|
||||
|
||||
'''
|
||||
from .conftest import cpu_scaling_factor
|
||||
from .conftest import cpu_perf_headroom
|
||||
|
||||
pid: int = os.getpid()
|
||||
timeout: float = (
|
||||
|
|
@ -798,8 +798,9 @@ def test_cancel_via_SIGINT_other_task(
|
|||
if _friggin_windows: # smh
|
||||
timeout += 1
|
||||
|
||||
# add latency headroom for CPU freq scaling (auto-cpufreq et al.)
|
||||
headroom: float = cpu_scaling_factor()
|
||||
# latency headroom for static cpu-freq scaling + sustained-load
|
||||
# throttle + CI (auto-cpufreq et al.); see `cpu_perf_headroom()`.
|
||||
headroom: float = cpu_perf_headroom()
|
||||
if headroom != 1.:
|
||||
timeout *= headroom
|
||||
|
||||
|
|
@ -1002,11 +1003,11 @@ def test_fast_graceful_cancel_when_spawn_task_in_soft_proc_wait_for_daemon(
|
|||
if _friggin_windows: # smh
|
||||
timeout += 1
|
||||
|
||||
# CPU-scaling / CI latency headroom — macOS CI especially is
|
||||
# slow for this graceful-vs-hard-reap timing race; see
|
||||
# `cpu_scaling_factor()`.
|
||||
from .conftest import cpu_scaling_factor
|
||||
timeout *= cpu_scaling_factor()
|
||||
# CPU-scaling / sustained-throttle / CI latency headroom — macOS
|
||||
# CI especially is slow for this graceful-vs-hard-reap timing
|
||||
# race; see `cpu_perf_headroom()`.
|
||||
from .conftest import cpu_perf_headroom
|
||||
timeout *= cpu_perf_headroom()
|
||||
|
||||
async def main():
|
||||
start = time.time()
|
||||
|
|
|
|||
|
|
@ -326,11 +326,11 @@ def time_quad_ex(
|
|||
):
|
||||
timeout += 1
|
||||
|
||||
# inflate the cancel-deadline for CPU-freq scaling AND/OR CI
|
||||
# latency (see `cpu_scaling_factor()`) so the example isn't
|
||||
# cancelled mid-stream on a throttled/CI runner.
|
||||
from .conftest import cpu_scaling_factor
|
||||
timeout *= cpu_scaling_factor()
|
||||
# inflate the cancel-deadline for static cpu-freq scaling +
|
||||
# sustained-load throttle + CI latency (see `cpu_perf_headroom()`)
|
||||
# so the example isn't cancelled mid-stream on a throttled/CI box.
|
||||
from .conftest import cpu_perf_headroom
|
||||
timeout *= cpu_perf_headroom()
|
||||
|
||||
start: float = time.time()
|
||||
results: list[int] = trio.run(partial(
|
||||
|
|
@ -379,8 +379,8 @@ def test_a_quadruple_example(
|
|||
# https://github.com/AdnanHodzic/auto-cpufreq?tab=readme-ov-file#example-config-file-contents
|
||||
#
|
||||
# HENCE this below latency-headroom compensation logic..
|
||||
from .conftest import cpu_scaling_factor
|
||||
headroom: float = cpu_scaling_factor()
|
||||
from .conftest import cpu_perf_headroom
|
||||
headroom: float = cpu_perf_headroom()
|
||||
if headroom != 1.:
|
||||
this_fast = this_fast_on_linux * headroom
|
||||
test_log.warning(
|
||||
|
|
|
|||
Loading…
Reference in New Issue