`sort`: Find a way to parallelize number parsing

Open
#8,061 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
cli, performance

Research direction

Start by inspecting chunks.rs, especially parse_lines and its side effects in line_data, then run the profiling setup described with sort -g. The work is done when number parsing is parallelized while preserving correct input order and avoiding a substantial single-thread performance loss.

Written by the indexing model from the issue text.

Description

U - sort

Especially after #8031 (pending PR), number parsing is a significant component of sort -g runtime (and possibly of other modes as well), maybe around ~70% of the runtime, as that part is single-threaded, while the sorting operation runs on multiple cores.

However, parallelizing chunks.rs parse_lines is challenging as there are side effects in line_data and we still need the data to be in the correct order. This might required extensive refactoring. We should find a way to make it parallel without sacrificing single-thread performance (at least not too much).

Testing setup:

seq 100 -0.000258 0 | sort -R > tmp/floatdata
cargo build --profile profiling -p uu_sort && samply record -r 10000 target/profiling/sort -g tmp/floatdata > /dev/null
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

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.

More from uutils/coreutils

All issues in uutils/coreutils

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.