`ls`: Investigate printing performance
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
In seq, we found that directly calling stdout.write_all(str.as_bytes())? is quite a bit faster than using format to do the same operation: write!(stdout, "{str}")?. https://github.com/uutils/coreutils/pull/7562
ls uses a lot of write!(..., "{}", ..)?; patterns. Would be nice to know if switching to write_all would improve performance.
Had a very quick look at samply output, and printing dominate more of the runtime in long format outputs (e.g. ls -l), so maybe it'd be good to start investigating that use case.
For reference, we're doing a bit worse than coreutils:
$ cargo build -r -p uu_ls && taskset -c 0 hyperfine --warmup 3 -L ls target/release/ls,ls "{ls} -lR .git"
Finished `release` profile [optimized] target(s) in 0.12s
Benchmark 1: target/release/ls -lR .git
Time (mean ± σ): 32.5 ms ± 0.8 ms [User: 18.7 ms, System: 13.5 ms]
Range (min … max): 31.2 ms … 34.4 ms 84 runs
Benchmark 2: ls -lR .git
Time (mean ± σ): 23.7 ms ± 1.5 ms [User: 11.3 ms, System: 12.0 ms]
Range (min … max): 23.0 ms … 38.6 ms 114 runs
Summary
ls -lR .git ran
1.37 ± 0.10 times faster than target/release/ls -lR .git
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the ls implementation by locating its write!(..., "{}", ..)? calls and compare them with seq's direct stdout.write_all pattern. Build the uu_ls release binary and run the provided hyperfine command against ls -lR .git; done means determining whether the output path improves performance and documenting the benchmark result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100