Skip to content

crc64

CI coverage

A pure-Go, SIMD-accelerated drop-in replacement for hash/crc64 (CGO_ENABLED=0, stable Go, no GOEXPERIMENT). It produces bit-identical CRC-64 checksums — for the predefined ISO and ECMA polynomials and for any custom polynomial — but folds the bulk of the input with the host's carryless-multiply unit instead of the scalar slicing-by-8 table. This is the first pure-Go SIMD crc64: the standard library and every existing Go crc64 library are scalar. Repository →

API

The API matches hash/crc64 exactly — change only the import path:

import "github.com/go-simd/crc64" // was "hash/crc64"

tab := crc64.MakeTable(crc64.ECMA)
sum := crc64.Checksum(data, tab)

h := crc64.New(tab)
h.Write(data)
_ = h.Sum64()

Checksum, Update, New, MakeTable, the ISO/ECMA constants, Size, the Table type (aliased to the stdlib type, so tables are interchangeable), and the hash.Hash64 returned by New (including BinaryMarshaler/BinaryUnmarshaler/AppendBinary) are all present.

Algorithm

The data is folded 16 bytes at a time into a single 128-bit reflected accumulator using carryless multiplication (the classic Intel "Fast CRC Computation"), then reduced to the 64-bit CRC. The fold constants are derived from the polynomial itself — reflect(x^191 mod P) and reflect(x^127 mod P) — so there are no copied magic numbers. The short tail (< 16 bytes) and the table build reuse the standard library, so results are guaranteed identical.

Per-arch kernels

arch instruction gate
amd64 PCLMULQDQ cpu.X86.HasPCLMULQDQ
arm64 PMULL / PMULL2 cpu.ARM64.HasPMULL
ppc64le VPMSUMD VSX (baseline, POWER8+)
s390x VGFMAG cpu.S390X.HasVX
riscv64 — (scalar fallback) Go does not yet expose Zbc
loong64 — (scalar fallback) no carryless multiply exposed

riscv64 and loong64 (and any CPU lacking the relevant instruction) transparently fall back to the standard-library scalar path — Go's released assembler exposes no carryless-multiply on those targets. Assembly is generated by go-asmgen (kernel_*_gen.go, committed alongside the .s).

Performance — honest

ECMA polynomial, single call over a buffer of the given size.

Native arm64 (Apple M-series, PMULL):

size this package hash/crc64 speedup
1 KiB 3824 MB/s 2065 MB/s 1.9×
16 KiB 7613 MB/s 2034 MB/s 3.7×
1 MiB 8271 MB/s 1977 MB/s 4.2×

The crossover is a few hundred bytes; below minBulk (512 B) the package uses the scalar path, so small inputs are never slower than the standard library.

amd64 (PCLMULQDQ): correctness-validated on real x86-64; same large-buffer advantage (≈2× in a virtualized measurement environment, higher on native silicon).

s390x (VGFMAG): measured on real IBM z15 (VXE2) (2026-07-03, -count=6): the vector Galois-field-multiply folding kernel runs ~9.1× the hash/crc64 scalar path on a bulk buffer. ppc64le (VPMSUMD): QEMU-validated for correctness; native perf pending a real POWER system.

Coverage

FuzzChecksum compares against hash/crc64 (ISO and ECMA) on arbitrary inputs, plus exhaustive length sweeps across all block boundaries for ISO, ECMA and a custom polynomial. CI runs native amd64/arm64 and QEMU riscv64/loong64/ppc64le (power9)/s390x, with a 100% statement-coverage gate on every architecture. BSD-3-Clause.