百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

murmur3

> 编程语言
开源

在 Go 中快速、完整的 murmur3。

352 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

在 Go 中快速、完整的 murmur3。

murmur3

Native Go implementation of Austin Appleby's third MurmurHash revision (aka MurmurHash3).

Includes 32, 64, and 128 bit sums, seeding functions, string functions that hash without converting to a slice, and streaming hashes implementing Go's standard Hash and Cloner interfaces.

This library started as a fork of spaolacci/murmur3. The reference algorithm has been slightly hacked as to support the streaming mode required by Go's standard Hash interface.

Endianness

Unlike the canonical source, this library always reads bytes as little endian numbers. This makes the hashes portable across architectures, although does mean that hashing is a bit slower on big endian architectures.

Safety

This library uses no unsafe. Bytes are read with plain indexing, which the compiler turns into single word sized loads on architectures that allow unaligned access, and the loops are shaped so that the compiler proves every index in bounds. Strings are hashed through one implementation generic over string | []byte, so hashing a string does not copy it and does not allocate.

Assembly

Earlier versions shipped hand rolled amd64 assembly for the 64 and 128 bit sums. That assembly was removed once the compiler's output caught up: as of Go 1.27, the pure Go code is faster than the old assembly for every input under 64 bytes, for keys of varying length, and for every 32 bit sum, and 1 to 7 percent slower on fixed inputs of 64 bytes and more. The 32 bit assembly was removed for the same reason back in Go 1.11. See the benchmarks below.

Testing

Testing includes comparing random inputs against the canonical implementation, and testing length 0 through 100 inputs to force the block loop, the trailing block, and all tail lengths.

Because this code always reads input as little endian, testing against the canonical source is skipped for big endian architectures. The canonical source just converts bytes to numbers, meaning on big endian architectures, it will use different numbers for its hashing.

Benchmarks

Cycles per call from perf (cycles:u at a fixed iteration count, minimum of three runs) on a Comet Lake i7-10710U, so CPU frequency and thermal throttling drop out. asm is the amd64 assembly this library shipped through v1.1.8; the other columns are this code built by that Go release. Go 1.26 is the minimum this module declares. Sizes rows exercise the block loop, Branches rows the 0 to 16 byte tail, and RandomLengths rows draw an xorshift length in [0, 64) on every call.

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Go

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言