Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using blake3 hashes and skipping empty blocks #29

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

awels
Copy link
Contributor

@awels awels commented Sep 17, 2024

Blake3 hashes are significantly faster than blake2 hashes used previously. Also added faster empty block detection so those don't need to get hashed at all.

@awels
Copy link
Contributor Author

awels commented Oct 8, 2024

/cc @rayfordj If you could review?

f.log.V(5).Info("Comparing hash of hashes", "hash", base64.StdEncoding.EncodeToString(f.hashHash))
if n, err := rw.Write(f.hashHash); err != nil {
return false, err
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: no need for an else statement here

Copy link
Contributor Author

@awels awels Oct 8, 2024

Choose a reason for hiding this comment

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

Actually I do need the else here, because I am referencingn which only exists in the scope of the if statement.

if n, err := io.ReadFull(rw, hashHash); err != nil {
return false, err
} else {
f.log.V(5).Info("Read hash of hashes", "bytes", n, "hash", base64.StdEncoding.EncodeToString(hashHash))
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same reason the else exists.

@@ -64,7 +64,7 @@ var _ = Describe("hasher tests", func() {
Expect(err).ToNot(HaveOccurred())
hashes := hasher.GetHashes()
// 16 for the blocksize and length, 72 for each hash
Copy link
Contributor

Choose a reason for hiding this comment

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

fix comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@dymurray dymurray left a comment

Choose a reason for hiding this comment

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

Just some nits, but aside from that VISIACK

Blake3 hashes are significantly faster than blake2
hashes used previously. Also added faster empty block
detection so those don't need to get hashed at all.

Signed-off-by: Alexander Wels <[email protected]>
@awels
Copy link
Contributor Author

awels commented Oct 8, 2024

Fixed the comment, the elses are still needed because of a variable only visible in the scope of the if statement.

Copy link

@pranavgaikwad pranavgaikwad left a comment

Choose a reason for hiding this comment

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

Overall looks good.

@@ -30,6 +36,7 @@ type Hasher interface {
SerializeHashes(io.Writer) error
DeserializeHashes(io.Reader) (int64, map[int64][]byte, error)
BlockSize() int64
CompareHashHash(io.ReadWriter) (bool, error)

Choose a reason for hiding this comment

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

find this name confusing, maybe s/HashHash/HashOfHash/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Renamed hashhash to hashofhash

Signed-off-by: Alexander Wels <[email protected]>
@dymurray dymurray merged commit 0a019b1 into migtools:master Oct 16, 2024
1 check passed
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.

3 participants