| 79 | |
| 80 | |
| 81 | def _timeout_cpu(root: Path) -> Sample: |
| 82 | # A contended acquire with a zero poll interval should spin on the clock, not the CPU. Hold the lock, time out a |
| 83 | # second acquirer, and report the CPU time the wait burned; a busy loop would show wall-sized CPU here. |
| 84 | holder = FileLock(str(root / "timeout.lock")) |
| 85 | holder.acquire() |
| 86 | waiter = FileLock(str(root / "timeout.lock")) |
| 87 | try: |
| 88 | started = time.process_time() |
| 89 | with suppress(filelock.Timeout): |
| 90 | waiter.acquire(timeout=0.25, poll_interval=0.0) |
| 91 | cpu = time.process_time() - started |
| 92 | finally: |
| 93 | holder.release() |
| 94 | return Sample(name="timeout cpu (0.25s wall, poll=0)", median=cpu * 1e3, p95=cpu * 1e3, unit="ms cpu") |
| 95 | |
| 96 | |
| 97 | def _descriptor_growth(root: Path) -> Sample: |