Skip to content

Commit

Permalink
More optimizations I think
Browse files Browse the repository at this point in the history
  • Loading branch information
Stridsvagn69420 committed Jun 25, 2023
1 parent 586a137 commit 7252c10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exclude = [
]

[dependencies]
blake3 = { version = "1.4", features = ["rayon"] }
blake3 = { version = "1.4", features = ["rayon", "neon"] }
kagero = { version = "0.4", default-features = false, features = ["printer"] }

[profile.release]
Expand Down
14 changes: 8 additions & 6 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ pub(crate) fn hasher(path: &Path) -> io::Result<Hash> {
let mut buffer = vec![0; bsize];

loop {
let bytes_read = f.read(&mut buffer)?;
if bytes_read == 0 {
break;
match f.read(&mut buffer) {
Ok(0) => return Ok(hasher.finalize()),
Ok(n) => {
hasher.update(&buffer[..n]);
},
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => continue,
Err(e) => return Err(e)
}
hasher.update_rayon(&buffer[..bytes_read]);
};
Ok(hasher.finalize())
}
}

/// Buffer Size
Expand Down

1 comment on commit 7252c10

@Stridsvagn69420
Copy link
Owner Author

Choose a reason for hiding this comment

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

Bruh, I'm stupid.
I was wondering why the time jumped from "close to b3sum" to "b3sum but with 1000 ms added". I forgot to change the update() to the rayon_update()

Please sign in to comment.