Skip to content

comm: compare lines with the locale collation - #14047

Open
luantaraschi wants to merge 1 commit into
uutils:mainfrom
luantaraschi:fix/comm-locale-collation
Open

comm: compare lines with the locale collation#14047
luantaraschi wants to merge 1 commit into
uutils:mainfrom
luantaraschi:fix/comm-locale-collation

Conversation

@luantaraschi

Copy link
Copy Markdown
Contributor

sort orders lines with the locale collation and comm reads that order back
with a byte comparison. In a UTF-8 locale where the two disagree, comm rejects
a file sort has just produced and puts lines in the wrong column.

With LC_ALL=en_US.UTF-8, f1 holding a1 then a-b, which is the order
sort gives, and f2 holding a-b:

command GNU before after
comm -12 f1 f2 a-b nothing, the shared line is dropped a-b
comm -13 f1 f2 nothing a-b, a line that is in both files nothing
comm -23 f1 f2 a1 a1 and a-b a1
exit code 0 1 0

sort, join, ls and expr already go through uucore::i18n::collator, and
join, which has the same order check, reads this input correctly today. This
gives comm the same comparison. In the C locale the lines are still compared
as bytes, so nothing changes there.

#12280 also touches OrderChecker, but for a different thing: it changes when
the warning is printed, not how the order is measured.

Fixes #12912

#12972 was closed as a duplicate of that one. It is an AOSP build failing after
45 minutes with comm: file 1 is not in sorted order.

sort orders lines with the locale collation, and comm read that order
back with a byte comparison. In a UTF-8 locale where the two disagree,
comm rejected a file sort had just produced and put lines in the wrong
column: comm -12 dropped the line the two files share, comm -23 reported
a shared line as unique, and the exit code was 1 where GNU gives 0.

sort, join, ls and expr already compare through uucore::i18n::collator.
join has the same order check and reads this input correctly, so comm
now uses the same comparison. In the C locale the lines are still
compared as bytes.
Copilot AI lite review requested due to automatic review settings August 20, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 152.79 MB (+1.20 MB, +0.79%)

Significant per-binary changes:
  comm     1.13 MB ->    2.33 MB  (+1.20 MB, +106.57%)

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)

@codspeed-hq

codspeed-hq Bot commented Aug 21, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.14%

⚠️ 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

⚡ 1 improved benchmark
✅ 356 untouched benchmarks
⏩ 50 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation cksum_crc32b 40.3 ms 38.7 ms +4.14%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing luantaraschi:fix/comm-locale-collation (cec5ab2) with main (0ecfd3b)

Open in CodSpeed

Footnotes

  1. 50 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.

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.

Comm complains about input sort order

2 participants