Categorygithub.com/mhr3/adler32-simd
repositorypackage
0.3.0
Repository: https://github.com/mhr3/adler32-simd.git
Documentation: pkg.go.dev

# README

adler32-simd

This package implements Adler32 hashing with SIMD acceleration for improved performance on modern processors.

Overview

Adler32 is a common checksum algorithm. This implementation uses SIMD instructions to parallelize computations and achieve significantly faster hashing speeds on supported hardware (amd64 CPUs with at least SSE3 support and arm64 CPUs with NEON) compared to golang's standard library.

The implementation is based on the zlib code in Chromium and has been transpiled to Go assembly using gocc.

Features

  • SIMD-accelerated Adler32 hashing for supported processors
  • Fallback to standard Go implementation for CPUs without SIMD support
  • Easy-to-use API that matches the standard library's hash/adler32 package

Performance

Benchmarks were performed on various CPU architectures. The following results show the performance of the SIMD-accelerated implementation compared to the standard library implementation for hashing a 1kB buffer:

CPUStandard LibrarySIMD-acceleratedSpeedup
Intel Core i7-8565U2213.71 MB/s26709.75 MB/s12.07x
Intel Xeon Platinum 8375C2895.98 MB/s31288.46 MB/s10.80x
AMD EPYC 9R143596.89 MB/s45258.16 MB/s12.58x
AWS Graviton21682.56 MB/s12801.97 MB/s7.61x
AWS Graviton32204.88 MB/s19564.81 MB/s8.87x
AWS Graviton42598.37 MB/s22169.60 MB/s8.53x
Apple M13007.11 MB/s35972.47 MB/s11.96x
Apple M1 (amd64 via Rosetta)2849.05 MB/s6287.86 MB/s2.21x

Usage

import "github.com/mhr3/adler32-simd"

data := []byte("Hello, World!")
checksum := adler32.Checksum(data)