Skip to content

tr: use POSIX_FADV_SEQUENTIAL#13506

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

tr: use POSIX_FADV_SEQUENTIAL#13506
wtcpython wants to merge 2 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 improve performance by 3.43%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
✅ 336 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ls_recursive_balanced_tree[(6, 4, 15)] 51.2 ms 49.4 ms +3.57%
Simulation du_all_wide_tree[(5000, 500)] 16.8 ms 16.2 ms +3.57%
Simulation du_max_depth_balanced_tree[(6, 4, 10)] 26.1 ms 25.3 ms +3.14%

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 wtcpython:tr-sequential-fadvise (ce062e0) with main (be96f5d)

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.

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

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