From 75d67d196ddc8b427d5971faab154917eae8cd92 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 14 May 2026 14:52:03 +0200 Subject: [PATCH] blake3: add to requirements and borg benchmark cpu --- pyproject.toml | 1 + src/borg/archiver/benchmark_cmd.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index de1f852d5..c4ab56bde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ dependencies = [ "xxhash>=2.0.0", "jsonargparse>=4.47.0", "PyYAML>=6.0.2", # we need to register our types with yaml, jsonargparse uses yaml for config files + "blake3>=1.0.0", ] [project.optional-dependencies] diff --git a/src/borg/archiver/benchmark_cmd.py b/src/borg/archiver/benchmark_cmd.py index 6cf5a4f1e..e436a5ec4 100644 --- a/src/borg/archiver/benchmark_cmd.py +++ b/src/borg/archiver/benchmark_cmd.py @@ -232,16 +232,20 @@ class BenchmarkMixIn: print(f"{spec:<24} {format_file_size(size):<10} {dt:.3f}s") from ..crypto.low_level import hmac_sha256, blake2b_256 + import blake3 if not args.json: print("Cryptographic hashes / MACs ====================================") else: result["hashes"] = [] size = 1000000000 - for spec, func in [ + hashes_tests = [ ("hmac-sha256", lambda: hmac_sha256(key_256, random_10M)), ("blake2b-256", lambda: blake2b_256(key_256, random_10M)), - ]: + ("blake3", lambda: blake3.blake3(random_10M, key=key_256).digest()), + ("blake3-mt", lambda: blake3.blake3(random_10M, key=key_256, max_threads=blake3.blake3.AUTO).digest()), + ] + for spec, func in hashes_tests: dt = timeit(func, number=number_default) if args.json: result["hashes"].append({"algo": spec, "size": size, "time": dt})