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

head: performance is pretty bad for non-seekable files #7372

Open
karlmcdowall opened this issue Mar 1, 2025 · 0 comments
Open

head: performance is pretty bad for non-seekable files #7372

karlmcdowall opened this issue Mar 1, 2025 · 0 comments
Labels

Comments

@karlmcdowall
Copy link
Contributor

On my laptop, I get the following results when running benchmarks for non-seekable files...

hyperfine  "cat shakespeare.txt | head -n -100000"     "cat shakespeare.txt | ./target/release/head -n -100000"

Summary
  cat shakespeare.txt | head -n -100000 ran
   16.03 ± 1.60 times faster than cat shakespeare.txt | ./target/release/head -n -100000



hyperfine  "cat shakespeare.txt | head -c -100000"     "cat shakespeare.txt | ./target/release/head -c -100000"

Summary
  cat shakespeare.txt | head -c -100000 ran
   18.56 ± 1.61 times faster than cat shakespeare.txt | ./target/release/head -c -100000

So the current Rust implementation is a lot slower than GNU for non-seekable files.

I have some changes drafted to resolve this and they seem to be work well. I need to tidy up the code and then I'll post with updated benchmarking results.

@karlmcdowall karlmcdowall changed the title Head performance is pretty bad for non-seekable files head: performance is pretty bad for non-seekable files Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants