Skip to content

Conversation

@RenjiSann
Copy link
Collaborator

@RenjiSann RenjiSann commented Nov 3, 2025

This PR adds several improvements:

  • Introduce the AlgoKind enum to stop relying on string comparison for checking algorithm behaviors
  • Introduce the SizedAlgokind enum to simply represent an algorithm with a given size.
  • cksum sanitization for BLAKE2b's length
  • Most importantly: Merging the digest computation for cksum and hashsum, so we don't have different implementations anymore. The only difference now happens in cli interpretation, but the underlying is now the same on both sides

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 4, 2025

CodSpeed Performance Report

Merging #9135 will improve performances by ×510

Comparing RenjiSann:cksum-reworks (6d6a991) with main (b0f41e7)

Summary

⚡ 6 improvements
✅ 120 untouched
⏩ 6 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
cksum_blake3 95,717.6 µs 187.2 µs ×510
cksum_crc 17.7 ms 17.2 ms +2.99%
cksum_crc32b 14.1 ms 13.6 ms +3.65%
cksum_default 17.7 ms 17.2 ms +2.88%
cksum_multiple_files 26.5 ms 25.8 ms +2.83%
cksum_raw_output 17.7 ms 17.2 ms +2.85%

Footnotes

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

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@RenjiSann RenjiSann force-pushed the cksum-reworks branch 2 times, most recently from db8fb3c to 36c93eb Compare November 4, 2025 01:33
@github-actions
Copy link

github-actions bot commented Nov 4, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@RenjiSann RenjiSann changed the title cksum: Various improvements cksum/hashsum: merge digest computation & various improvements Nov 6, 2025
@RenjiSann RenjiSann marked this pull request as ready for review November 6, 2025 17:20
@RenjiSann RenjiSann requested a review from sylvestre November 6, 2025 17:20
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

Copy link
Contributor

@sylvestre sylvestre left a comment

Choose a reason for hiding this comment

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

Windows builds are failing

@RenjiSann
Copy link
Collaborator Author

Windows builds are failing

Yes, this is being discussed in #9168, I will move the PR back to draft until it's fixed

@RenjiSann RenjiSann marked this pull request as draft November 9, 2025 15:27
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@RenjiSann RenjiSann marked this pull request as ready for review November 14, 2025 23:04
@RenjiSann RenjiSann requested a review from sylvestre November 18, 2025 01:18
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

(algo @ (ak::Sha2 | ak::Sha3), None) => {
Err(ChecksumError::LengthRequiredForSha(algo.to_lowercase().into()).into())
}
// [`calculate_blake2b_length`] expects a length in bits but we
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment says 'expects a length in bits' but the multiplication by 8 suggests the input is in bytes ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, l is a length in bytes and we multiply it to give the length in bits to the function

let mut digest = algo.create_digest();
let (calculated_checksum, _) =
digest_reader(&mut digest, &mut file_reader, opts.binary, algo.bits).unwrap();
digest_reader(&mut digest, &mut file_reader, false, algo.bitlen()).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a comment why it is now "false" ? :)
(maybe we should also improve the function profile not to use a bool)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe we should also improve the function profile not to use a bool

I plan on doing that at some point, but I reserve that to a later patch, once #9168 is properly determined


// This test is currently disabled on windows
#[test]
#[cfg_attr(windows, ignore = "Discussion is in #9168")]
Copy link
Contributor

Choose a reason for hiding this comment

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

very interesting issue


let opts = ChecksumOptions {
binary,
let opts = ChecksumValidateOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we could remove it for validate_opts ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I understand this comment

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@sylvestre sylvestre merged commit 643a72c into uutils:main Nov 20, 2025
127 checks passed
@RenjiSann RenjiSann deleted the cksum-reworks branch November 20, 2025 09:55
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.

2 participants