Skip to content

tail: report the follow mode actually used with --debug - #16670

Merged
sylvestre merged 3 commits into
uutils:mainfrom
costajohnt:fix/tail-debug-polling-mode
Nov 24, 2026
Merged

sylvestre merged 3 commits into
uutils:mainfrom
costajohnt:fix/tail-debug-polling-mode

Conversation

@costajohnt

Copy link
Copy Markdown
Contributor

--debug always printed using notification mode, once, before the initial output. Now the mode line comes when following actually starts, and it names the mode in use:

  • -f with no regular-file input (e.g. /dev/null, a piped stdin) prints using blocking mode, and -F on the same prints using polling mode, as in the issue.
  • When a watched directory is removed and tail reverts to polling, using polling mode follows inotify cannot be used, reverting to polling (once, even with several files in that directory).
  • No mode line is printed when following never starts (tail --debug -f missing).

Only the reported message changes for devices and FIFOs; the watcher underneath is the same.

The new tests cover the blocking and polling cases, the missing-file case and the switch to polling. The directory tests rename the directory before deleting its files and wait for tail's own output before the next step, so they don't depend on timing.

Closes #16643

--debug always printed "using notification mode", once, before the
initial output. Print the mode only once following actually starts,
report blocking mode (-f) or polling mode (-F) when no input (stdin
included) is a regular file, and report the switch to polling the first
time a watched directory is removed.

Closes uutils#16643
Comment thread src/uu/tail/src/follow/watch.rs Outdated
@@ -540,11 +548,37 @@ fn report_inaccessible(display_name: &str) {
}

#[allow(clippy::cognitive_complexity)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this allow now applies to print_follow_mode instead of follow, so clippy is red. please move the new fn above it

Comment thread tests/by-util/test_tail.rs Outdated
// already gone whenever tail handles the removal.
at.rename("dir", "dir.gone");
at.remove("dir.gone/f");
for _ in 0..100 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same wait loop is here 3 times, could you please add a small helper?

@sylvestre

Copy link
Copy Markdown
Contributor

thanks for the PR!
print_follow_mode was added between #[allow(clippy::cognitive_complexity)] and follow(), so clippy fails on follow now (the wasm/msys lint jobs). please fix it and get CI green.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.49 MB (+104 KB, +0.07%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

Put the cognitive_complexity allow back on follow(), drop the WASI stub
Observer field that is no longer read, and classify stdin with fstat on
fd 0 instead of stat on /dev/stdin.
@costajohnt

Copy link
Copy Markdown
Contributor Author

Thanks! Moved the #[allow(clippy::cognitive_complexity)] back onto follow in 644bab1. Two other CI failures were from this PR too, so they're in the same commit:

  • wasm lint: the WASI stub Observer still had a use_polling field nothing read any more, so it's a unit struct now.
  • Android: the new piped-stdin --debug test printed "notification mode". The check stat'ed /dev/stdin, which doesn't map to fd 0 there, so it now uses fstat on stdin like args.rs does. It only changes which mode --debug reports, and on Linux the result is the same as before.

The MSYS failure (mv: cannot stat 'target/release-small/deps/stdbuf.dll') also shows up on unrelated PRs.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/tail/debug is no longer failing!
Congrats! The gnu test tests/tail/follow-name is no longer failing!
Congrats! The gnu test tests/tail/pid-pipe is no longer failing!

Comment thread src/uu/tail/src/follow/watch.rs Outdated
let no_regular_file = settings.inputs.iter().all(|input| match input.kind() {
InputKind::File(path) => path.metadata().is_ok_and(|md| !md.is_file()),
#[cfg(unix)]
InputKind::Stdin => rustix::fs::fstat(std::io::stdin())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same fstat check as stdin_is_regular in args.rs, could be a small shared helper, no?

@sylvestre

Copy link
Copy Markdown
Contributor

thanks for this PR!
the wait loop in the tests is still there 3 times, please add the helper.

@costajohnt

Copy link
Copy Markdown
Contributor Author

Thanks! Both done:

  • the three wait loops now go through a small wait_for_stderr(&mut child, |stderr| ...) helper
  • the fstat check is now paths::stdin_is_regular(), used by both args.rs and watch.rs

About the red checks on the last push, I don't think they come from the diff:

  • "Style and Lint" and "Style/lint (wasm32-wasip1)" stopped before clippy ran, because sccache couldn't start (ServerBusy: Egress is over the account limit from the GHA cache)
  • "L10n/Locale Embedding - Cargo Install" failed on "Could not find embedded_locales.rs" after building uu_yes, and this PR only touches tail

Locally, clippy -D warnings on uu_tail is clean (also the tail tests built for the linux target), the wasm32-wasip1 clippy command from that job passes, and fmt and cspell pass too.

@codspeed

codspeed Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 7.53%

1 warning, 1 note

⚠️ 123 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 410 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation socket_addrs_direct[100000] 104.8 µs 132.3 µs -20.78%
❌ CPU Simulation hostname_ip_lookup[100000] 155.7 µs 185.5 µs -16.03%
⚡ CPU Simulation false_consecutive_calls 350.2 ns 294.7 ns +18.85%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing costajohnt:fix/tail-debug-polling-mode (3c1522f) with main (293a724)2

Open in CodSpeed

Footnotes

  1. 70 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. ↩

  2. No successful run was found on main (91f89c4) during the generation of this report, so 293a724 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@sylvestre
sylvestre merged commit e47e3e6 into uutils:main Nov 24, 2026
200 of 202 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tail: --debug always says notification mode and misses the switch to polling

2 participants