Skip to content

util: Add BLAKE3 hash support

Tatsuyuki Ishi requested to merge ishitatsuyuki/mesa:blake3 into main

In !18644, there were some complaints about Mesa's SHA1 implementation being slow.

Instead of trying to find and integrate SHA-1 assembly from a variety of places, why not replace it with something more modern?

This MR adds a copy of blake3 hashing library into Mesa. BLAKE3 was chosen because it's fast, and there is an actively maintained official implementation, which is used by ccache and llvm.

There are some potential build system issues that can happen with old compiler versions, which we should keep an eye on. I also had to patch symbol visibility in util/blake3: Patch with hidden visibility for asm symbols. to comply with the shared object export policy.

As a preliminary benchmark, I replaced all sha1 calls with BLAKE3 truncated to 160-bits (not in this MR), and ran fossilize-replay with a warm shader cache (cache hits only). I used --loop 20 which also happens to shift the majority of cost to hashing, because this way Fossilize only does the JSON parsing once. Still, it sufficiently demonstrates how faster BLAKE3 hashing is.

main (e84cf80f): 5824ms

This MR: 2393ms (-59%)

Edited by Tatsuyuki Ishi

Merge request reports

Loading