Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tail: Performance improvements #7522

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

karlmcdowall
Copy link
Contributor

Not ready for review yet, I need to write some unit-tests for the backwards_thru_file fn (since it doesn't currently have any). Just want to see what CI thinks of it and if it blows up...

These are the performance gains I see...

$ hyperfine "/usr/bin/tail -n +100000 ./shakespeare.txt" "./target/release/tail.original -n +100000 ./shakespeare.txt" "./target/release/tail -n +100000 ./shakespeare.txt"
Benchmark 1: /usr/bin/tail -n +100000 ./shakespeare.txt
  Time (mean ± σ):       4.1 ms ±   0.3 ms    [User: 2.1 ms, System: 2.0 ms]
  Range (min … max):     3.8 ms …   5.6 ms    597 runs
 
Benchmark 2: ./target/release/tail.original -n +100000 ./shakespeare.txt
  Time (mean ± σ):       5.4 ms ±   0.3 ms    [User: 3.8 ms, System: 1.5 ms]
  Range (min … max):     4.9 ms …   6.3 ms    461 runs
 
Benchmark 3: ./target/release/tail -n +100000 ./shakespeare.txt
  Time (mean ± σ):       3.2 ms ±   0.3 ms    [User: 1.8 ms, System: 1.4 ms]
  Range (min … max):     2.8 ms …   4.9 ms    704 runs
 
Summary
  ./target/release/tail -n +100000 ./shakespeare.txt ran
    1.31 ± 0.13 times faster than /usr/bin/tail -n +100000 ./shakespeare.txt
    1.69 ± 0.16 times faster than ./target/release/tail.original -n +100000 ./shakespeare.txt

and

$ hyperfine "/usr/bin/tail -n 100000 ./shakespeare.txt" "./target/release/tail.original -n 100000 ./shakespeare.txt" "./target/release/tail -n 100000 ./shakespeare.txt"
Benchmark 1: /usr/bin/tail -n 100000 ./shakespeare.txt
  Time (mean ± σ):       4.6 ms ±   0.4 ms    [User: 2.4 ms, System: 2.1 ms]
  Range (min … max):     4.2 ms …   7.2 ms    430 runs
 
Benchmark 2: ./target/release/tail.original -n 100000 ./shakespeare.txt
  Time (mean ± σ):       4.4 ms ±   0.3 ms    [User: 2.9 ms, System: 1.5 ms]
  Range (min … max):     3.9 ms …   6.7 ms    595 runs
 
Benchmark 3: ./target/release/tail -n 100000 ./shakespeare.txt
  Time (mean ± σ):       3.4 ms ±   0.3 ms    [User: 2.1 ms, System: 1.3 ms]
  Range (min … max):     3.0 ms …   5.1 ms    715 runs
 
Summary
  ./target/release/tail -n 100000 ./shakespeare.txt ran
    1.28 ± 0.14 times faster than ./target/release/tail.original -n 100000 ./shakespeare.txt
    1.35 ± 0.16 times faster than /usr/bin/tail -n 100000 ./shakespeare.txt

So not an order-of-magnitude gain, but a nice little boost none the less.

@karlmcdowall karlmcdowall force-pushed the tail_forwards_through_file branch from 9b5e464 to 5dbd1f5 Compare March 22, 2025 01:30
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/misc/stdbuf is no longer failing!

sylvestre added a commit to sylvestre/coreutils that referenced this pull request Mar 22, 2025
sylvestre added a commit to sylvestre/coreutils that referenced this pull request Mar 22, 2025
sylvestre added a commit to sylvestre/coreutils that referenced this pull request Mar 22, 2025
sylvestre added a commit to sylvestre/coreutils that referenced this pull request Mar 22, 2025
@sylvestre sylvestre force-pushed the tail_forwards_through_file branch from 5dbd1f5 to 723d436 Compare March 22, 2025 20:53
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@sylvestre sylvestre force-pushed the tail_forwards_through_file branch from 723d436 to e2db689 Compare March 23, 2025 08:13
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@cakebaker cakebaker changed the title tail: Performace improvements tail: Performance improvements Mar 23, 2025
sylvestre added a commit to sylvestre/coreutils that referenced this pull request Mar 25, 2025
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.

1 participant