https://github.com/octu0/pch
Power Consistent Hashing
https://github.com/octu0/pch
consistent-hash-algorithm consistent-hashing
Last synced: 8 months ago
JSON representation
Power Consistent Hashing
- Host: GitHub
- URL: https://github.com/octu0/pch
- Owner: octu0
- License: mit
- Created: 2024-05-03T12:51:45.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-03T12:53:20.000Z (almost 2 years ago)
- Last Synced: 2025-05-22T10:13:21.191Z (10 months ago)
- Topics: consistent-hash-algorithm, consistent-hashing
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `pch`
[](https://github.com/octu0/pch/blob/master/LICENSE)
[](https://pkg.go.dev/github.com/octu0/pch)
[](https://goreportcard.com/report/github.com/octu0/pch)
[](https://github.com/octu0/pch/releases)
Go implementation of [Power Consistent Hashing](https://arxiv.org/pdf/2307.12448.pdf) algorithm.
## Installation
```bash
go get github.com/octu0/pch
```
## Example
```go
import (
"hash/fnv"
"github.com/octu0/pch"
)
func main() {
p := pch.New(512, fnv.New64()) // 512 buckets, hash function fnv.New64()
p.Hash("hello world")
}
```
## Benchmark
```
$ go test -bench=Benchmark .
goos: linux
goarch: amd64
pkg: github.com/octu0/pch
cpu: Intel(R) Xeon(R) W-11955M CPU @ 2.60GHz
Benchmark/jump/512-16 15240927 76.51 ns/op
Benchmark/jump/1024-16 14898984 79.36 ns/op
Benchmark/jump/2048-16 14624468 81.27 ns/op
Benchmark/jump/4096-16 14171553 84.87 ns/op
Benchmark/jump/8192-16 13739763 86.91 ns/op
Benchmark/power/512-16 9934183 117.4 ns/op
Benchmark/power/1024-16 10374721 119.1 ns/op
Benchmark/power/2048-16 10252898 117.2 ns/op
Benchmark/power/4096-16 10489959 118.0 ns/op
Benchmark/power/8192-16 10361293 117.0 ns/op
PASS
```
# License
MIT, see LICENSE file for details.