Replies: 3 comments 11 replies
-
This discussion prompted me to add a benchmark for hash functions to Bazel: #22017 The preliminary result is that while BLAKE3 is about 8x faster than SHA2-256 on Linux x86_64, I found it to 25% slower on an M3 Mac. That is surprising, but if true, we would of course need to fix that before pursuing making it the default. Edit: It's not that surprising since NEON only has 128 bit SIMD registers and Apple Silicon provides highly optimized hardware intrinsics for SHA256 (BLAKE3-team/BLAKE3#315). Edit: Nvm, I forgot FYI @brentleyjones |
Beta Was this translation helpful? Give feedback.
-
BLAKE3 advertises itself as being faster than SHA-256. But it is important to realize that these gains only appear on larger inputs. For small inputs the performance of BLAKE3 is significantly worse than SHA-256. Especially if you perform builds with remote execution and '--remote_download_minimal' enabled, you spend an awful amount of time hashing small objects. Not large ones. Think of the steps that Bazel needs to perform to construct a Merkle tree of an action. Many, many, many messages that are less than a kilobyte in size. I therefore think that it's fine to have Bazel support BLAKE3, but enabling it by default? That doesn't sound like a good idea. |
Beta Was this translation helpful? Give feedback.
-
From the conversation above, I concluded that there is no significant motivation for us to switch away from the default hashing algorithm anytime soon. 👍 Closing this. |
Beta Was this translation helpful? Give feedback.
-
Currently, we are using SHA256 as the default hash function of Bazel. However, for builds with large binary artifacts, alternative hash functions such as SHA256Tree, Blake3, or PSHA2 perform much better.
Among these newer hash algorithms, Blake3 is quite popular and other build tools have started to adopt it. The tooling is also widely available with
b3sum
CLI https://crates.io/crates/b3sum being a direct replacement forsha256sum
.So this discussion is to put forward the idea that we should flip the default to Blake3 in a future version of Bazel (8?), and start accounting for the tasks needed to make it happen.
Beta Was this translation helpful? Give feedback.
All reactions