Skip to content

A commutative hasher that supports parallel and out-of-order computation - #156

Open
bb8gh wants to merge 2 commits into
mainfrom
bb8gh/commutative-hasher
Open

A commutative hasher that supports parallel and out-of-order computation#156
bb8gh wants to merge 2 commits into
mainfrom
bb8gh/commutative-hasher

Conversation

@bb8gh

@bb8gh bb8gh commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

This is useful in situations where a hash of a large file is needed, but the file is processed non-sequentially (such as blocks being downloaded in parallel). The hash can be built up in any order but still produce the same value for the same input data.

This is useful in situations where a hash of a large file is needed, but the file is processed non-sequentially (such as blocks being downloaded in parallel). The hash can be built up in any order but still produce the same value for the same input data.
Copilot AI balanced review requested due to automatic review settings September 4, 2026 22:59
@bb8gh
bb8gh requested a review from a team as a code owner September 4, 2026 22:59

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 review overview

🟡 Changes recommended

Block alignment is not fully enforced, and sequential offsets can overflow on 32-bit targets.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 2 Medium severity · 2 Low severity

New issues introduced by this change (5)
Severity Finding
High severity crates/​commutative_hasher/​src/​lib.rs — This cumulative offset can overflow on 32-bit targets after a sequential stream exceeds 4 GiB.…
Medium severity crates/​commutative_hasher/​src/​lib.rs — The documented alignment contract is not enforced for data.len(). Any short slice is accepted at…
Medium severity crates/​commutative_hasher/​src/​lib.rs — This 128 MiB hashing test runs in the default suite, despite the repository's explicit `make…
Low severity crates/​commutative_hasher/​README.md — The subject is singular, so “always get” should be “always gets.”
Low severity crates/​commutative_hasher/​README.md — This Rust example cannot compile: ... is not Rust syntax and no digest value is initialized…
What changed in this PR

Adds a commutative, block-based Rust hasher supporting parallel and out-of-order processing.

Changes:

  • Adds parallel/sequential hashers and digest serialization.
  • Adds tests, documentation, and workspace integration.
  • Adds optional serde support.
File Description
README.md Lists the new crate.
Makefile Tests serde support.
crates/​commutative_hasher/​src/​lib.rs Implements hashers, digests, and tests.
crates/​commutative_hasher/​README.md Documents usage and behavior.
crates/​commutative_hasher/​Cargo.toml Defines crate metadata and dependencies.
Suppressed comments (1)

crates/commutative_hasher/src/lib.rs:542

  • This parameterized test hashes and allocates 128 MiB six times in every default test run, and the serde command runs it all again. The repository routes expensive tests through make test-ignored (Makefile:44-48); please mark this test ignored or use a much smaller multi-block fixture.
    #[rstest]
    fn test_hash_large_value_sequential(#[values(1, 2, 8, 10, 60, 200)] num_chunks: usize) {
        let expected_digest = "ee7338897f6eaf9b4f26b6ec33d3192bca8231485ac70d64fc81128397af0755";
        let data = generate_data(1 << 27); // 128 MiB

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/commutative_hasher/src/lib.rs
Comment thread crates/commutative_hasher/src/lib.rs
Comment thread crates/commutative_hasher/src/lib.rs
Comment thread crates/commutative_hasher/README.md Outdated
Comment thread crates/commutative_hasher/README.md
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