Fastmurmur3 - Fast non-cryptographic hash, with the benchmarks to prove it.

Overview

GitHub Contributors Stars Build Status Downloads Crates.io

Fastmurmur3

Murmur3 is a fast, non-cryptographic hash function. fastmurmur3 is, in my testing, the fastest implementation of Murmur3.

Usage

let bytes: &[u8] = b"hello world";
let x: u128 = fastmurmur3::hash(bytes);

Installation

cargo install fastmurmur3

Benchmarks

Summary

According to current benchmarks (and excluding FxHasher):

  • fastmurmur3 is the fastest.
  • xxh3_64 is 1.66x slower and only has a 64-bit value.
  • xxh3_128 is 2.50x slower.
  • fasthash contains the next fastest murmur3 implementation, but is still 4.47x slower than fastmurmur3.

Data

rustc_hash::FxHasher    time:   [243.91 ps 244.60 ps 245.30 ps]

fastmurmur3             time:   [3.0878 ns 3.1215 ns 3.1619 ns]
xxhash_rust::xxh3_64    time:   [5.1473 ns 5.1872 ns 5.2456 ns]
xxhash_rust::xxh3_128   time:   [7.8066 ns 7.8271 ns 7.8499 ns]
fasthash                time:   [13.909 ns 13.960 ns 14.018 ns]
murmur3c                time:   [14.529 ns 14.604 ns 14.684 ns]
murmur3                 time:   [26.084 ns 26.163 ns 26.249 ns]
twox_hash::Xxh3Hash64   time:   [124.23 ns 126.46 ns 128.55 ns]
twox_hash::Xxh3Hash128  time:   [134.62 ns 136.75 ns 138.77 ns]
sha1                    time:   [209.55 ns 211.71 ns 214.88 ns]

Benchmark Future Work

  • These benchmarks are run on a limited input set and with a limited seed set. These more extensive benchmarks need to happen before definitively making the claim that fastmurmur3 is the fastest non-cryptographic hash function.

  • Besides speed, these benchmarks could also measure other important hash properties like collision-resistance in comparison to other algorithms (xxhash, etc.).

  • I exclude FxHash from the benchmark summary because I don't know if it's been tested for general use beyond the rust compiler. If that has been done, and it proves to be general purpose, FxHash could be preferable to fastmurmur3.

  • It'd be nice to have pretty charts of the benchmarks.

Correctness

The tests for fastmurmur3 perform fuzzing in comparison to the C implementation.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request
You might also like...
cargo-generate template for Criterion benchmarks

Criterion Benchmark Template This is a cargo-generate template for quickly creating benchmarks using the Criterion benchmarking framework. Usage $ car

specs & benchmarks for the ZPrize 3 - High Throughput Signature Verification

Zprize: High Throughput Signature Verification How fast do you think you can verify our ECDSA signatures on Aleo? This year's Zprize is winner-take-al

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

A (mostly) pure-Rust implementation of various cryptographic algorithms.

Rust-Crypto A (mostly) pure-Rust implementation of various common cryptographic algorithms. Rust-Crypto seeks to create practical, auditable, pure-Rus

Highly modular & configurable hash & crypto library
Highly modular & configurable hash & crypto library

Octavo Highly modular & configurable hash & crypto library written in pure Rust. Installation [dependencies] octavo = { git = "https://github.com/libO

Modern Cryptographic Firmware

Trussed® Modern Cryptographic Firmware Status Very much WIP. Actively developed. Unstable APIs.

The underlying cryptographic primitives for Manta Ecosystem

manta crypto The underlying cryptography that manta ecosystem relies on. It comes with the following traits: checksum: definitions for message digest.

Secure storage for cryptographic secrets in Rust

secrets secrets is a library to help Rust programmers safely held cryptographic secrets in memory. It is mostly an ergonomic wrapper around the memory

Pure Rust implementation of the RNCryptor cryptographic format by Rob Napier

rncryptor Rust Implementation of the RNCryptor spec This library implements the specification for the RNCryptor encrypted file format by Rob Napier. d

Owner
Kurt Wolf
Kurt Wolf
the official Rust and C implementations of the BLAKE3 cryptographic hash function

BLAKE3 is a cryptographic hash function that is: Much faster than MD5, SHA-1, SHA-2, SHA-3, and BLAKE2. Secure, unlike MD5 and SHA-1. And secure again

BLAKE3 team 3.7k Jan 6, 2023
Lockstitch is an incremental, stateful cryptographic primitive for symmetric-key cryptographic operations in complex protocols.

Lockstitch is an incremental, stateful cryptographic primitive for symmetric-key cryptographic operations (e.g. hashing, encryption, message authentication codes, and authenticated encryption) in complex protocols.

Coda Hale 3 Dec 27, 2022
Rust implementation of the PTHash perfect hash function for static compile-time generated hash tables

QuickPHF QuickPHF is a Rust implementation of the PTHash minimal perfect hash function algorithm. It consists of two crates: quickphf - runtime code f

Darko Trifunovski 11 Oct 20, 2023
Expose various non-cryptographic hashing functions with Digest traits

noncrypto-digests Expose various non-cryptographic hashing functions with Digest traits. This allows users to use any hashing function with the same t

Yuri Astrakhan 3 Dec 9, 2023
deductive verification of Rust code. (semi) automatically prove your code satisfies your specifications!

Le marteau-pilon, forges et aciéries de Saint-Chamond, Joseph-Fortuné LAYRAUD, 1889 About Creusot is a tool for deductive verification of Rust code. I

Xavier Denis 609 Dec 28, 2022
🛠️ Uses zkevm-circuits and anvil mainnetfork to prove that a tx solves an EVM challenge

zk-proof-of-evm-execution This is a PoC developed at hackathon that enables a user to prove that they know some calldata that can solve a challenge on

soham 9 Mar 29, 2023
A "Type 0" zkEVM. Prove validity of Ethereum blocks using RISC Zero's zkVM

zeth NEW: Zeth now supports Optimism blocks! Just pass in --network=optimism! Zeth is an open-source ZK block prover for Ethereum built on the RISC Ze

RISC Zero 222 Oct 26, 2023
Sodium Oxide: Fast cryptographic library for Rust (bindings to libsodium)

sodiumoxide |Crate|Documentation|Gitter| |:---:|:-----------:|:--------:|:-----:|:------:|:----:| |||| NaCl (pronounced "salt") is a new easy-to-use h

sodiumoxide 642 Dec 17, 2022
Blazing fast Pedersen hash implementation for Node.JS

pedersen-fast Blazing fast Pedersen hash implementation for Node.JS Exposes starknet-crypto's implementation written in Rust as WASM package. Usage np

L2BEAT 7 Mar 10, 2023
Benchmarks of most widely used web frameworks built in rust.

Rust framework benchmarks Benchmarking utility to test the performance of all the rust web frameworks. Built with rust ?? . Demo (Last updated: Thu Ju

Ishtmeet Singh 4 Oct 21, 2022