Skip to content

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
@github-actions
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
@github-actions
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
@github-actions
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
@karlmcdowall karlmcdowall force-pushed the tail_forwards_through_file branch from e2db689 to 410f458 Compare March 26, 2025 01:27
@karlmcdowall karlmcdowall force-pushed the tail_forwards_through_file branch from 410f458 to 5af7bab Compare March 26, 2025 01:30
@github-actions
Copy link

GNU testsuite comparison:

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

MoSal pushed a commit to MoSal/coreutils that referenced this pull request Mar 26, 2025
nickorlow pushed a commit to nickorlow/coreutils that referenced this pull request Jul 17, 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