Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tensorush/zig-mementohash

Zig implementation of MementoHash consistent hashing algorithm.
https://github.com/tensorush/zig-mementohash

consistent-hash consistent-hash-algorithm consistent-hash-ring consistent-hashing consistent-hashing-library hash hash-ring hashing mementohash zig zig-language zig-library zig-package zig-port ziglang

Last synced: 29 days ago
JSON representation

Zig implementation of MementoHash consistent hashing algorithm.

Awesome Lists containing this project

README

        

# zig-mementohash

[![CI][ci-shield]][ci-url]
[![CD][cd-shield]][cd-url]
[![DC][dc-shield]][dc-url]
[![LC][lc-shield]][lc-url]

## Zig implementation of [MementoHash consistent hashing algorithm](https://arxiv.org/abs/2306.09783).

### :rocket: Usage

- Add `mementohash` dependency to `build.zig.zon`.

```sh
zig fetch --save https://github.com/tensorush/zig-mementohash/archive/.tar.gz
```

- Use `mementohash` dependency in `build.zig`.

```zig
const mementohash_dep = b.dependency("mementohash", .{
.target = target,
.optimize = optimize,
});
const mementohash_mod = mementohash_dep.module("MementoHash");
.root_module.addImport("MementoHash", mementohash_mod);
```

### :bar_chart: Benchmarks

- Speed: the time the algorithm needs to find the node the given key belongs to.

```sh
$ zig build bench -- -s
Elapsed time: 151.215ms
```

- Balance: the ability of the algorithm to spread the keys evenly across the cluster nodes.

```sh
$ zig build bench -- -b
Load balance: 7.84
```

- Monotonicity: the ability of the algorithm to move the minimum amount of resources when the cluster scales.

```sh
$ zig build bench -- -m
Number of misplaced keys after removal: 0.00%
Number of misplaced keys after restoring: 0.00%
```

[ci-shield]: https://img.shields.io/github/actions/workflow/status/tensorush/zig-mementohash/ci.yaml?branch=main&style=for-the-badge&logo=github&label=CI&labelColor=black
[ci-url]: https://github.com/tensorush/zig-mementohash/blob/main/.github/workflows/ci.yaml
[cd-shield]: https://img.shields.io/github/actions/workflow/status/tensorush/zig-mementohash/cd.yaml?branch=main&style=for-the-badge&logo=github&label=CD&labelColor=black
[cd-url]: https://github.com/tensorush/zig-mementohash/blob/main/.github/workflows/cd.yaml
[dc-shield]: https://img.shields.io/badge/click-F6A516?style=for-the-badge&logo=zig&logoColor=F6A516&label=docs&labelColor=black
[dc-url]: https://tensorush.github.io/zig-mementohash
[lc-shield]: https://img.shields.io/github/license/tensorush/zig-mementohash.svg?style=for-the-badge&labelColor=black
[lc-url]: https://github.com/tensorush/zig-mementohash/blob/main/LICENSE