coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Example of translation after parsing clap for performance

Open ChrisDryden opened this issue 2 weeks ago • 2 comments

I wanted to learn a bit about the performance characteristics of coreutils for the commands that were listed as being slower than the GNU implementations. One of the reasons listed for being slower is that the translation files are parsed even when they are not needed: https://github.com/uutils/coreutils/issues/9103

I was able to find some examples online of how you can add a wrapper to the clap parser that can modify the clap command if it recognizes that the help command is being called and then the translation keys can be obtained. When doing the original comparisons using hyperfine commands shown in that issue, my timing was similar to what was described in the issue but afterwards it moved from 2. ms to 1.0 ms.

Metric GNU ln uutils glibc
Speed 805 µs 1.0 ms

This tells me that after adding the fix for the translations to not be parsed, we have a clear path to replacing some of the glibc calls with more native functionality using nix and we should be able to perform faster than the GNU implementation.

ChrisDryden avatar Dec 09 '25 13:12 ChrisDryden

GNU testsuite comparison:

GNU test failed: tests/install/basic-1. tests/install/basic-1 is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/install/install-C. tests/install/install-C is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/install/install-C-root. tests/install/install-C-root is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/install/install-C-selinux. tests/install/install-C-selinux is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Dec 09 '25 13:12 github-actions[bot]

CodSpeed Performance Report

Merging #9615 will improve performances by 2.04%

Comparing ChrisDryden:translate_after_parse_idea (e2baf1c) with main (85aabf2)

Summary

⚡ 1 improvement
✅ 126 untouched
⏩ 6 skipped[^skipped]

Benchmarks breakdown

Benchmark BASE HEAD Change
tsort_input_parsing_heavy[5000] 84.6 ms 82.9 ms +2.04%
[^skipped]: 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

codspeed-hq[bot] avatar Dec 09 '25 13:12 codspeed-hq[bot]