uutils / uutils/coreutils

wc: wc -c does not optimize stdin as input by metadata

Open
#11,610 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - wc
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

We have splice for pipe at input:

$ truncate -s 32GB huge
$ time cat huge| gnu58d88d243/wc -c
32000000000

real	0m2.012s
user	0m0.128s
sys	0m3.873s
$ time cat huge| wc -c
32000000000

real	0m0.388s
user	0m0.042s
sys	0m0.650s

that's fine. But uutils does not optimize stdin by metadata:

$ time wc -c <huge
32000000000

real	0m1.662s
user	0m0.040s
sys	0m1.612s
$ time gnu58d88d243/wc -c < huge
32000000000

real	0m0.004s
user	0m0.002s
sys	0m0.002s

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the wc -c command path for stdin redirected from a regular file and reproduce the huge benchmark shown in the issue. Trace how stdin is read and how file metadata is used; done means the byte count remains correct while matching the metadata-based performance of GNU wc for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.