Skip to content

tr: use POSIX_FADV_SEQUENTIAL - #13506

Open
wtcpython wants to merge 3 commits into
uutils:mainfrom
wtcpython:tr-sequential-fadvise
Open

tr: use POSIX_FADV_SEQUENTIAL#13506
wtcpython wants to merge 3 commits into
uutils:mainfrom
wtcpython:tr-sequential-fadvise

Conversation

@wtcpython

Copy link
Copy Markdown
Contributor

Fixes #13121.

tr reads standard input sequentially but did not provide the kernel with a corresponding access-pattern hint.

Call fadvise with POSIX_FADV_SEQUENTIAL on standard input on supported platforms, treating it as a best-effort optimization so failures do not change command behavior. Add a Linux strace regression test that verifies the advice is issued.

@oech3

oech3 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

It is useful for file input. Not for stdin (which is stream at most cases).

Comment thread tests/by-util/test_tr.rs

let trace_file = at.plus_as_string("strace.out");
let result = Command::new("strace")
.args(["-o", &trace_file, "-e", "fadvise64,fadvise64_64"])

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 test does not check that fadvise is properly called for file's fd.

@oech3

oech3 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

OK. My issue is invalid at here:( . I misunderstood that pr accepts files as input.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/tail/pid is no longer failing!
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.

@codspeed-hq

codspeed-hq Bot commented Jul 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 339 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing wtcpython:tr-sequential-fadvise (8b8d5bf) with main (64bea9b)2

Open in CodSpeed

Footnotes

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

  2. No successful run was found on main (738afee) during the generation of this report, so 64bea9b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@sylvestre

Copy link
Copy Markdown
Contributor

@oech3 is that ok with you ?
thanks

@oech3

oech3 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

This is useful for the case pr < file args which is probaly very nich usecase.

@wtcpython
wtcpython force-pushed the tr-sequential-fadvise branch from c362211 to 8b8d5bf Compare July 27, 2026 08:18
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.

tr: Use POSIX_FADV_SEQUENTIAL

3 participants