Skip to content

sort, uniq, fold: name the input in a read error - #15191

Open
NdekoCode wants to merge 5 commits into
uutils:mainfrom
NdekoCode:read-errors-name-the-file
Open

NdekoCode wants to merge 5 commits into
uutils:mainfrom
NdekoCode:read-errors-name-the-file

Conversation

@NdekoCode

Copy link
Copy Markdown
Contributor

A read error said read failed: Is a directory (sort), read error: Is a directory (uniq) or failed to read line: Is a directory (fold), with no way to tell which of several inputs it was about. GNU 9.12 names the input, - for standard input: sort: read failed: d: Is a directory, uniq: error reading 'd': Is a directory, fold: d: Is a directory.

sort wraps each input in a reader that names itself in its errors, which keeps the chunk reader as it is; uniq and fold pass the name down to where the read happens. Checked against GNU 9.12 with a directory as an operand, on standard input, and among other inputs; the three suites pass. Part of what misc/read-errors.sh from #14705 checks.

Closes #15190.

@codspeed

codspeed Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 3.71%

⚠️ 31 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 1 benchmark has no flamegraph

The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 2 regressed benchmarks
✅ 70 untouched benchmarks
⏩ 400 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation uniq_case_insensitive[10000] 2.9 ms 3 ms -4.09%
❌ CPU Simulation uniq_with_count[10000] 3.6 ms 3.7 ms -3.32%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing NdekoCode:read-errors-name-the-file (735bc24) with main (ae34722)2

Open in CodSpeed

Footnotes

  1. 400 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. ↩

  2. No successful run was found on main (198c615) during the generation of this report, so ae34722 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Comment thread src/uu/sort/src/sort.rs Resolved
@NdekoCode
NdekoCode requested a review from sylvestre October 9, 2026 21:55
A read error said "read failed: Is a directory", "read error: Is a
directory" or "failed to read line: Is a directory", with no way to
tell which of several inputs it was about. GNU names the input, "-"
for standard input.

sort wraps each input in a reader that names itself in its errors,
uniq and fold pass the name down to where the read happens.
The name and the error are two parameters of sort-read-failed now, so
translators decide their order instead of the reader formatting both
into one string. The temporary files of a merge name themselves too,
as they do in GNU sort.
Both go through locale_aware_shell_escape, as the open error has
since 8edf725.
Reading a directory there fails with EBADF, not EISDIR.
@NdekoCode
NdekoCode force-pushed the read-errors-name-the-file branch from 0a9dcbd to 1252d86 Compare October 20, 2026 19:33
@NdekoCode

NdekoCode commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@sylvestre rebased on main, the merge inputs name their TmpPath.

Reading a directory there fails with EBADF, not EISDIR, like for fold.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sort, uniq, fold: a read error does not say which input failed

2 participants