0u.io/b3

b3

v1.0.0

go implementation of BLAKE3. it's dependency-free (golang.org/x/sys doesn't count). it focuses on high performance on modern platforms; it has AVX2, NEON, SVE2, SME (on apple silicon), and AVX-512 kernels. of note, the AVX-512 kernels interleave two 16-chunk groups to keep the vector ports busy; this is a win everywhere, but in particular on full-width (server/desktop) zen5 (which has 2-cycle vector integer ops) this is responsible for about a 37% improvement in the leaf kernel.

benchmarks

harness
machine bench measure

one thread · AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

higher is better#
0510152064B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

lower is better · log scale#
.25.51248163264B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

higher is better#
0510152064B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

lower is better · log scale#
.25.51248163264B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

higher is better#
17.3 GB/s
9.54 GB/s
1.12 GB/s
0.777 GB/s
12.8 GB/s
12.6 GB/s
0.771 GB/s
machine bench measure

AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

lower is better · log scale#
0.291 cycles/byte
0.528 cycles/byte
4.51 cycles/byte
6.51 cycles/byte
0.396 cycles/byte
0.398 cycles/byte
6.56 cycles/byte
machine bench measure

default thread count · AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

higher is better#
0100200300400
1 MiB
16 MiB
128 MiB

input size

machine bench measure

default thread count · AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

higher is better#
0246810
1 MiB
16 MiB
128 MiB

input size

machine bench measure

AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

lower is better#
big · default1 file · 268 MB
16.6 ms1.2× faster
19.7 ms
big · 1 thread1 file · 268 MB
38.7 ms1.3× faster
51.9 ms
fleet · default10,000 files · 208 MB
15.3 ms10.9× faster
166 ms
fleet · 1 thread10,000 files · 208 MB
66.9 ms1.3× faster
88.6 ms
fleet · --check10,000 files · 208 MB
15.9 ms10.1× faster
161 ms
mixed · default2,000 files · 1.03 GB
50.7 ms6.7× faster
339 ms
mixed · 1 thread2,000 files · 1.03 GB
160 ms1.1× faster
179 ms
machine bench measure

AMD Ryzen Threadripper 9980X 64-Cores · linux/amd64

lower is better#
big · default1 file · 268 MB
85.0 ms5.1× less cpu
436 ms
big · 1 thread1 file · 268 MB
38.5 ms1.3× less cpu
51.7 ms
fleet · default10,000 files · 208 MB
250 ms27.4× less cpu
6.83 s
fleet · 1 thread10,000 files · 208 MB
66.7 ms1.3× less cpu
89.0 ms
fleet · --check10,000 files · 208 MB
253 ms27.1× less cpu
6.86 s
mixed · default2,000 files · 1.03 GB
503 ms61.1× less cpu
30.8 s
mixed · 1 thread2,000 files · 1.03 GB
160 ms1.1× less cpu
178 ms
machine bench measure

one thread · AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

higher is better#
0258101264B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

lower is better · log scale#
.25.51248163264B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

higher is better#
0258101264B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

lower is better · log scale#
.25.51248163264B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

higher is better#
10.0 GB/s
7.28 GB/s
1.10 GB/s
0.776 GB/s
9.16 GB/s
9.18 GB/s
0.762 GB/s
machine bench measure

AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

lower is better · log scale#
0.486 cycles/byte
0.673 cycles/byte
4.52 cycles/byte
6.51 cycles/byte
0.537 cycles/byte
0.535 cycles/byte
6.55 cycles/byte
machine bench measure

default thread count · AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

higher is better#
0204060
1 MiB
16 MiB
128 MiB

input size

machine bench measure

default thread count · AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

higher is better#
02468
1 MiB
16 MiB
128 MiB

input size

machine bench measure

AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

lower is better#
big · default1 file · 268 MB
14.1 ms1.1× faster
15.2 ms
big · 1 thread1 file · 268 MB
44.3 ms1.2× faster
54.7 ms
fleet · default10,000 files · 208 MB
13.7 ms9.6× faster
131 ms
fleet · 1 thread10,000 files · 208 MB
73.7 ms1.3× faster
95.5 ms
fleet · --check10,000 files · 208 MB
15.2 ms8.4× faster
128 ms
mixed · default2,000 files · 1.03 GB
50.9 ms2.6× faster
134 ms
mixed · 1 thread2,000 files · 1.03 GB
179 ms1.1× faster
201 ms
machine bench measure

AMD Ryzen AI 9 HX 370 w/ Radeon 890M · linux/amd64

lower is better#
big · default1 file · 268 MB
135 ms
119 ms
big · 1 thread1 file · 268 MB
43.8 ms1.2× less cpu
54.4 ms
fleet · default10,000 files · 208 MB
177 ms5.8× less cpu
1.02 s
fleet · 1 thread10,000 files · 208 MB
74.7 ms1.3× less cpu
95.0 ms
fleet · --check10,000 files · 208 MB
179 ms5.6× less cpu
1.01 s
mixed · default2,000 files · 1.03 GB
554 ms3.7× less cpu
2.07 s
mixed · 1 thread2,000 files · 1.03 GB
177 ms1.1× less cpu
201 ms
machine bench measure

one thread · Intel(R) Core(TM) Ultra X9 388H · linux/amd64

higher is better#
0246864B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · Intel(R) Core(TM) Ultra X9 388H · linux/amd64

higher is better#
0246864B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

Intel(R) Core(TM) Ultra X9 388H · linux/amd64

higher is better#
5.90 GB/s
5.79 GB/s
0.975 GB/s
1.52 GB/s
1.93 GB/s
1.87 GB/s
1.01 GB/s
machine bench measure

default thread count · Intel(R) Core(TM) Ultra X9 388H · linux/amd64

higher is better#
01020304050
1 MiB
16 MiB
128 MiB

input size

machine bench measure

default thread count · Intel(R) Core(TM) Ultra X9 388H · linux/amd64

higher is better#
02468
1 MiB
16 MiB
128 MiB

input size

machine bench measure

Intel(R) Core(TM) Ultra X9 388H · linux/amd64

lower is better#
big · default1 file · 268 MB
13.7 ms
13.7 ms
big · 1 thread1 file · 268 MB
54.1 ms
54.6 ms
fleet · default10,000 files · 208 MB
18.3 ms9.7× faster
177 ms
fleet · 1 thread10,000 files · 208 MB
85.4 ms
89.3 ms
fleet · --check10,000 files · 208 MB
18.8 ms9.2× faster
172 ms
mixed · default2,000 files · 1.03 GB
44.7 ms2.9× faster
132 ms
mixed · 1 thread2,000 files · 1.03 GB
216 ms
215 ms
machine bench measure

Intel(R) Core(TM) Ultra X9 388H · linux/amd64

lower is better#
big · default1 file · 268 MB
115 ms
119 ms
big · 1 thread1 file · 268 MB
53.7 ms
54.1 ms
fleet · default10,000 files · 208 MB
181 ms6.3× less cpu
1.14 s
fleet · 1 thread10,000 files · 208 MB
85.6 ms
89.5 ms
fleet · --check10,000 files · 208 MB
187 ms6.2× less cpu
1.16 s
mixed · default2,000 files · 1.03 GB
520 ms2.6× less cpu
1.34 s
mixed · 1 thread2,000 files · 1.03 GB
215 ms
213 ms
machine bench measure

one thread · Intel(R) Xeon(R) 6975P-C · linux/amd64

higher is better#
024681064B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · Intel(R) Xeon(R) 6975P-C · linux/amd64

lower is better · log scale#
.25.51248163264B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · Intel(R) Xeon(R) 6975P-C · linux/amd64

higher is better#
024681064B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · Intel(R) Xeon(R) 6975P-C · linux/amd64

lower is better · log scale#
.25.5124816326464B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

Intel(R) Xeon(R) 6975P-C · linux/amd64

higher is better#
8.14 GB/s
6.34 GB/s
0.769 GB/s
1.10 GB/s
7.60 GB/s
7.59 GB/s
1.18 GB/s
machine bench measure

Intel(R) Xeon(R) 6975P-C · linux/amd64

lower is better · log scale#
0.470 cycles/byte
0.605 cycles/byte
5.04 cycles/byte
3.52 cycles/byte
0.510 cycles/byte
0.511 cycles/byte
3.30 cycles/byte
machine bench measure

default thread count · Intel(R) Xeon(R) 6975P-C · linux/amd64

higher is better#
05101520
1 MiB
16 MiB
128 MiB

input size

machine bench measure

default thread count · Intel(R) Xeon(R) 6975P-C · linux/amd64

higher is better#
0123456
1 MiB
16 MiB
128 MiB

input size

machine bench measure

Intel(R) Xeon(R) 6975P-C · linux/amd64

lower is better#
big · default1 file · 268 MB
25.5 ms
24.6 ms
big · 1 thread1 file · 268 MB
49.5 ms1.1× faster
52.8 ms
fleet · default10,000 files · 208 MB
32.7 ms3.1× faster
101 ms
fleet · 1 thread10,000 files · 208 MB
79.2 ms1.1× faster
89.7 ms
fleet · --check10,000 files · 208 MB
31.6 ms3.0× faster
94.1 ms
mixed · default2,000 files · 1.03 GB
95.6 ms1.3× faster
125 ms
mixed · 1 thread2,000 files · 1.03 GB
212 ms
212 ms
machine bench measure

Intel(R) Xeon(R) 6975P-C · linux/amd64

lower is better#
big · default1 file · 268 MB
85.8 ms
83.0 ms
big · 1 thread1 file · 268 MB
49.7 ms1.1× less cpu
52.7 ms
fleet · default10,000 files · 208 MB
112 ms1.9× less cpu
215 ms
fleet · 1 thread10,000 files · 208 MB
79.9 ms1.1× less cpu
90.4 ms
fleet · --check10,000 files · 208 MB
112 ms1.8× less cpu
207 ms
mixed · default2,000 files · 1.03 GB
355 ms1.1× less cpu
406 ms
mixed · 1 thread2,000 files · 1.03 GB
214 ms
213 ms
machine bench measure

one thread · Apple M6 · darwin/arm64

higher is better#
0246864B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · Apple M6 · darwin/arm64

higher is better#
0246864B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

Apple M6 · darwin/arm64

higher is better#
6.78 GB/s
3.09 GB/s
1.41 GB/s
1.26 GB/s
1.58 GB/s
1.63 GB/s
1.55 GB/s
machine bench measure

default thread count · Apple M6 · darwin/arm64

higher is better#
0102030
1 MiB
16 MiB
128 MiB

input size

machine bench measure

default thread count · Apple M6 · darwin/arm64

higher is better#
0.00.51.01.52.02.53.0
1 MiB
16 MiB
128 MiB

input size

machine bench measure

Apple M6 · darwin/arm64

lower is better#
big · default1 file · 268 MB
18.6 ms1.1× faster
20.1 ms
big · 1 thread1 file · 268 MB
56.7 ms2.1× faster
116 ms
fleet · default10,000 files · 208 MB
55.5 ms5.3× faster
294 ms
fleet · 1 thread10,000 files · 208 MB
141 ms1.4× faster
193 ms
fleet · --check10,000 files · 208 MB
54.2 ms5.4× faster
291 ms
mixed · default2,000 files · 1.03 GB
54.8 ms2.8× faster
156 ms
mixed · 1 thread2,000 files · 1.03 GB
224 ms2.0× faster
447 ms
machine bench measure

Apple M6 · darwin/arm64

lower is better#
big · default1 file · 268 MB
139 ms1.2× less cpu
163 ms
big · 1 thread1 file · 268 MB
55.3 ms2.1× less cpu
115 ms
fleet · default10,000 files · 208 MB
528 ms3.0× less cpu
1.56 s
fleet · 1 thread10,000 files · 208 MB
140 ms1.4× less cpu
192 ms
fleet · --check10,000 files · 208 MB
530 ms2.9× less cpu
1.56 s
mixed · default2,000 files · 1.03 GB
558 ms2.2× less cpu
1.21 s
mixed · 1 thread2,000 files · 1.03 GB
222 ms2.0× less cpu
446 ms
machine bench measure

one thread · Neoverse V3 (part 0xd84) · linux/arm64

higher is better#
0123464B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · Neoverse V3 (part 0xd84) · linux/arm64

lower is better · log scale#
1248163264B1K2K4K8K12K16K64K1M16M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · Neoverse V3 (part 0xd84) · linux/arm64

higher is better#
0123464B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

one thread · Neoverse V3 (part 0xd84) · linux/arm64

lower is better · log scale#
1248163264B1K16K1M

input size (K = KiB, M = MiB), log scale

machine bench measure

Neoverse V3 (part 0xd84) · linux/arm64

higher is better#
3.17 GB/s
1.68 GB/s
0.852 GB/s
0.746 GB/s
1.08 GB/s
1.04 GB/s
0.943 GB/s
machine bench measure

Neoverse V3 (part 0xd84) · linux/arm64

lower is better · log scale#
1.03 cycles/byte
1.94 cycles/byte
3.84 cycles/byte
4.39 cycles/byte
3.03 cycles/byte
3.15 cycles/byte
3.48 cycles/byte
machine bench measure

default thread count · Neoverse V3 (part 0xd84) · linux/arm64

higher is better#
0258101215
1 MiB
16 MiB
128 MiB

input size

machine bench measure

default thread count · Neoverse V3 (part 0xd84) · linux/arm64

higher is better#
01234
1 MiB
16 MiB
128 MiB

input size

machine bench measure

Neoverse V3 (part 0xd84) · linux/arm64

lower is better#
big · default1 file · 268 MB
32.5 ms1.5× faster
49.8 ms
big · 1 thread1 file · 268 MB
103 ms1.7× faster
174 ms
fleet · default10,000 files · 208 MB
32.5 ms3.5× faster
115 ms
fleet · 1 thread10,000 files · 208 MB
110 ms1.6× faster
179 ms
fleet · --check10,000 files · 208 MB
32.1 ms3.4× faster
110 ms
mixed · default2,000 files · 1.03 GB
105 ms2.0× faster
210 ms
mixed · 1 thread2,000 files · 1.03 GB
392 ms1.7× faster
667 ms
machine bench measure

Neoverse V3 (part 0xd84) · linux/arm64

lower is better#
big · default1 file · 268 MB
104 ms1.7× less cpu
174 ms
big · 1 thread1 file · 268 MB
103 ms1.7× less cpu
174 ms
fleet · default10,000 files · 208 MB
113 ms2.7× less cpu
305 ms
fleet · 1 thread10,000 files · 208 MB
110 ms1.6× less cpu
179 ms
fleet · --check10,000 files · 208 MB
112 ms2.6× less cpu
297 ms
mixed · default2,000 files · 1.03 GB
399 ms1.9× less cpu
739 ms
mixed · 1 thread2,000 files · 1.03 GB
393 ms1.7× less cpu
667 ms
machine

b3sum

Command b3sum computes and checks BLAKE3 checksums, compatible with the upstream b3sum.

go install 0u.io/b3sum@latest
b3sum --tag *.tar.zst > SUMS
b3sum --check SUMS

reducing performance

0u.io/b3 is cgo-free but uses liberal amounts of asm everywhere; it does support the purego build tag to fall back to the scalar implementation. it also supports GOEXPERIMENT=simd (in conjunction with purego).

changelog

  1. v1.0.0latest2026-10-18pkg.go.dev ↗ srcb3sum
    • initial release.

index

import "0u.io/b3"

constants

const (
	// Size is the default digest length in bytes.
	Size = 32
	// BlockSize is the compression block length in bytes.
	BlockSize = 64
	// KeySize is the key length for NewKeyed in bytes.
	KeySize = 32
)

functions

funcDeriveKey

func DeriveKey(context string, material []byte) [Size]byte

DeriveKey returns the 32-byte key derived from material in the given context. context should be a hardcoded, globally unique application string.

funcSum256

func Sum256(data []byte) [Size]byte

Sum256 returns the unkeyed BLAKE3 digest of data.

funcSum256Keyed

func Sum256Keyed(key [KeySize]byte, data []byte) [Size]byte

Sum256Keyed returns the keyed BLAKE3 digest of data.

types

typeError

type Error string

Error is the type of every error this package returns.

const (
	ErrXOFSeekEnd      Error = "cannot seek from end of xof"
	ErrXOFSeekWhence   Error = "bad seek whence"
	ErrXOFSeekNegative Error = "negative xof offset"
	ErrXOFSeekOverflow Error = "xof position exceeds int64"
)

func (Error)Error

func (e Error) Error() string

typeHasher

type Hasher struct {
	// contains filtered or unexported fields
}

Hasher is a hash.Hash for streaming BLAKE3 state.

funcNew

func New(opts ...Option) *Hasher

New returns a Hasher for the regular hash mode.

funcNewDeriveKey

func NewDeriveKey(context string, opts ...Option) *Hasher

NewDeriveKey returns a Hasher for the key derivation mode: write the key material, read the derived key out. context should be a hardcoded, globally unique application string.

funcNewKeyed

func NewKeyed(key []byte, opts ...Option) *Hasher

NewKeyed returns a Hasher that uses the 32-byte key. it panics on any other length.

func (*Hasher)BlockSize

func (h *Hasher) BlockSize() int

BlockSize returns the compression block length (64).

func (*Hasher)Clone

func (h *Hasher) Clone() (hash.Cloner, error)

Clone returns an independent copy of the state. it never fails.

func (*Hasher)Reset

func (h *Hasher) Reset()

Reset restores the state to as-created, including key and mode if applicable.

func (*Hasher)Size

func (h *Hasher) Size() int

Size returns the digest length (32).

func (*Hasher)Sum

func (h *Hasher) Sum(b []byte) []byte

Sum appends the digest of the data written to b and returns the resulting slice.

func (*Hasher)Write

func (h *Hasher) Write(p []byte) (int, error)

Write absorbs p. it never fails.

func (*Hasher)XOF

func (h *Hasher) XOF() *OutputReader

XOF returns a reader over the output of the data written. the reader is an independent snapshot.

typeOption

type Option func(*Hasher)

Option configures a Hasher.

funcWithParallelism

func WithParallelism(n int) Option

WithParallelism enables multi-goroutine hashing of large writes, with at most n workers; n <= 0 picks automatically. applying it to a live Hasher between Writes is supported.

typeOutputReader

type OutputReader struct {
	// contains filtered or unexported fields
}

OutputReader streams the output of a finalized hash. it implements io.Reader and io.Seeker.

func (*OutputReader)Read

func (r *OutputReader) Read(p []byte) (int, error)

func (*OutputReader)Seek

func (r *OutputReader) Seek(offset int64, whence int) (int64, error)

Seek repositions the stream. offsets past 2^63-1 are rejected because io.Seeker returns an int64, and io.SeekEnd is rejected outright.