-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Simplify blake3 hasher and improve performance #19041
Conversation
fb651a5
to
3c81c52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I like this change not only because it improves the performance but also makes the code easier to read/maintain.
flush(); | ||
} | ||
buffer.put(b); | ||
engineUpdate(new byte[] {b}, 0, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know whether creating a temporary array here will impact performance (and I have no idea when this method will be called), but can we avoid doing that? For example, we could have a 1 sized byte array buffer created ahead of time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
3c81c52
to
4ee7857
Compare
The changes in this PR have been included in Bazel 6.4.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc. |
Improve BLAKE3 performance by reducing copies.
Rather than buffering bytes, it's faster to just update the blake3 hasher as bytes are hashed.
Performance with buffering:
Performance without buffering (after this CL):