klauspost/crc32

CRC32 hash with x64 optimizations

83

stars

51

commits

Assembly

primary language

Jul 22, 2025

updated

README

2025 revival

For IEEE checksums AVX512 can be used to speed up CRC32 checksums by approximately 2x.

Castagnoli checksums (CRC32C) can also be computer with AVX512, but the performance gain is not as significant enough for the downsides of using it at this point.

crc32

This package is a drop-in replacement for the standard library hash/crc32 package, that features AVX 512 optimizations on x64 platforms, for a 2x speedup for IEEE CRC32 checksums.

usage

Install using go get github.com/klauspost/crc32. This library is based on Go 1.24

Replace import "hash/crc32" with import "github.com/klauspost/crc32" and you are good to go.

changes

  • 2025: Revived and updated to Go 1.24, with AVX 512 optimizations.

performance

AVX512 are enabled above 1KB input size. This rather high limit is due to AVX512 may be slower to ramp up than the regular SSE4 implementation for smaller inputs. This is not reflected in the benchmarks below.

BenchmarkOld MB/sNew MB/sSpeedup
BenchmarkCRC32/poly=IEEE/size=512/align=0-3217996.3917969.941.00x
BenchmarkCRC32/poly=IEEE/size=512/align=1-3218021.4817945.551.00x
BenchmarkCRC32/poly=IEEE/size=1kB/align=0-3219921.7045613.772.29x
BenchmarkCRC32/poly=IEEE/size=1kB/align=1-3219946.6046819.092.35x
BenchmarkCRC32/poly=IEEE/size=4kB/align=0-3221538.6548600.932.26x
BenchmarkCRC32/poly=IEEE/size=4kB/align=1-3221449.2048477.842.26x
BenchmarkCRC32/poly=IEEE/size=32kB/align=0-3221785.4946013.102.11x
BenchmarkCRC32/poly=IEEE/size=32kB/align=1-3221946.4745954.102.09x

cpu: AMD Ryzen 9 9950X 16-Core Processor

license

Standard Go license. See LICENSE for details.

Contributors

klauspost

43 commits

dmitshur

2 commits

wangtuanjie

2 commits

rsc

1 commits

klauspost/crc32

CRC32 hash with x64 optimizations

83

stars

51

commits

Assembly

primary language

Jul 22, 2025

updated

README

2025 revival

For IEEE checksums AVX512 can be used to speed up CRC32 checksums by approximately 2x.

Castagnoli checksums (CRC32C) can also be computer with AVX512, but the performance gain is not as significant enough for the downsides of using it at this point.

crc32

This package is a drop-in replacement for the standard library hash/crc32 package, that features AVX 512 optimizations on x64 platforms, for a 2x speedup for IEEE CRC32 checksums.

usage

Install using go get github.com/klauspost/crc32. This library is based on Go 1.24

Replace import "hash/crc32" with import "github.com/klauspost/crc32" and you are good to go.

changes

  • 2025: Revived and updated to Go 1.24, with AVX 512 optimizations.

performance

AVX512 are enabled above 1KB input size. This rather high limit is due to AVX512 may be slower to ramp up than the regular SSE4 implementation for smaller inputs. This is not reflected in the benchmarks below.

BenchmarkOld MB/sNew MB/sSpeedup
BenchmarkCRC32/poly=IEEE/size=512/align=0-3217996.3917969.941.00x
BenchmarkCRC32/poly=IEEE/size=512/align=1-3218021.4817945.551.00x
BenchmarkCRC32/poly=IEEE/size=1kB/align=0-3219921.7045613.772.29x
BenchmarkCRC32/poly=IEEE/size=1kB/align=1-3219946.6046819.092.35x
BenchmarkCRC32/poly=IEEE/size=4kB/align=0-3221538.6548600.932.26x
BenchmarkCRC32/poly=IEEE/size=4kB/align=1-3221449.2048477.842.26x
BenchmarkCRC32/poly=IEEE/size=32kB/align=0-3221785.4946013.102.11x
BenchmarkCRC32/poly=IEEE/size=32kB/align=1-3221946.4745954.102.09x

cpu: AMD Ryzen 9 9950X 16-Core Processor

license

Standard Go license. See LICENSE for details.

Contributors

klauspost

43 commits

dmitshur

2 commits

wangtuanjie

2 commits

rsc

1 commits

Languages

Assembly

77.1%

Go

22.9%