Skip to content

test_no_delay flaky: probe overestimates expected saving #9234

Description

@nGoline

Summary

test_no_delay (in tests/test_connection.py) is failing intermittently across multiple CI configurations (ASan/UBSan, Full Integration, etc.), including on retries.

Root Cause

Commit 91c8c37 ("fix nagle time delay for macOS-Issue #9064") introduced an adaptive probe: 10 round-trips are timed with Nagle enabled and without, and the per-RTT difference is used to compute expected_saving, which then gates the assertion for the full 100-trip run.

The 10-sample probe has high variance and consistently overestimates the per-RTT Nagle delay by ~2x relative to the full run. When the probe overestimates, expected_saving is set too high and the assertion fails even though Nagle disabling is clearly working.

Failing assertions from CI

# assert normal_time < nagle_time - expected_saving
assert 21.80726671218872 < (28.225794553756714 - 7.359144687652589)
assert 25.825435400009155 < (31.75627374649048 - 6.155816316604614)
assert 14.281448602676392 < (22.333508729934692 - 9.02500867843628)

All three cases show a real, clear saving (19-36%) — the test is just asserting too aggressively based on the noisy probe.

Example failing runs

Fix

Halve the required saving in the strict-check branch (expected_saving / 2 instead of expected_saving). This gives a 4x total discount from the raw probe estimate (2x already baked in for Nagle average, 2x more for probe noise), while still catching a real regression where TCP_NODELAY is not set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions