Skip to content

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

Closed
@karlmcdowall

Description

@karlmcdowall

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions