tests/tail: speed up follow/retry tests with event-based waits - #13695
tests/tail: speed up follow/retry tests with event-based waits#13695sankalpsthakur wants to merge 2 commits into
Conversation
Replace fixed multi-second sleeps in the slowest test_tail::* cases with
polling helpers that return as soon as the expected stdout/stderr appears.
Also add short -s.1/--max-unchanged-stats=1 where follow/polling latency
was dominated by the default 1s sleep interval.
Helpers added to UChild (non-consuming peeks + wait_until /
wait_for_{stdout,stderr}_contains / wait_until_exited) keep later
assertions intact while allowing generous timeouts for slow CI.
Fixes uutils#10097
AI disclosure: this change was developed with AI assistance (Grok).
I reviewed the full diff and the approach (event-based waits rather than
shorter fixed sleeps) follows maintainer guidance on the issue.
|
GNU testsuite comparison: |
test_follow_name_move_create1 raced under event-based waits: renaming as soon as stdout was non-empty, and killing after "has appeared" before the recreated file content was printed. Wait for END(25) before rename and START(0) after re-open on Linux.
Merging this PR will improve performance by 3.03%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | cksum_crc32b |
40.9 ms | 39.7 ms | +3.03% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing sankalpsthakur:fix/10097-tail-test-runtime (cf343cb) with main (86b5562)
Footnotes
-
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
In the future, please write shorter comment 0 I am a human and I don't want to read long llm Ai comment |
|
Understood. will keep comments short. |
| "-s.1", | ||
| "--max-unchanged-stats=1", |
There was a problem hiding this comment.
The fixed per-OS sleeps (100–2000 ms) were replaced by event-based waits (wait_for_stdout_contains(..., WAIT_TIMEOUT)), so each assertion returns as soon as the expected bytes appear. But tail only emits new content on its poll cadence, the -s sleep interval which defaults to 1s, so once the sleeps were gone, tail's own interval became the dominant latency (that is also why the old macOS delay had to be 2000 ms). -s.1 lowers it to 100 ms so the event-based waits actually resolve promptly.
--max-unchanged-stats=1 is the same knob on the --follow=name path: tail re-stats the file by name after one unchanged stat instead of the default 5, so appends/replacement are noticed within a poll cycle or two rather than after multiple full intervals. WAIT_TIMEOUT stays a generous 5s upper bound; in practice these assertions now return in well under a second.
There was a problem hiding this comment.
to be blunt, if i wanted an answer from a LLM, i would have done it myself ;)
Fixes #10097 - speed up slow
test_tailfollow/retry cases by polling for expected output instead of fixed sleeps (5s timeout). Adds wait helpers inuutestsand uses-s.1where sleep interval dominated latency.Test:
cargo test --features unix --test tests test_tail -- --test-threads=1AI-assisted; I reviewed the diff.