GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - OpenHFT/Zero-Allocation-Hashing: Zero-allocation hashing for Java

BranchesTags
Open more actions menu

Latest commit

 

History

266 Commits
266 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.mvn/wrapper
.mvn/wrapper
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
AGENTS.md
AGENTS.md
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
README.adoc
README.adoc
 
 
mvnw
mvnw
 
 
mvnw-in-be-docker
mvnw-in-be-docker
 
 
mvnw.cmd
mvnw.cmd
 
 
pom.xml
pom.xml
 
 

Repository files navigation

Zero-Allocation Hashing

Table of Contents
  • About
    • Performance
    • When to use Zero-Allocation Hashing
    • When not to use Zero-Allocation Hashing
    • Javadoc
    • Internal documentation
  • Quick start
  • Contributions are most welcome!

Chronicle Software

zero allocation hashing javadoc GitHub release%20notes subscribe brightgreen measure?project=OpenHFT Zero Allocation Hashing&metric=alert status

About

This project provides a Java API for hashing any sequence of bytes in Java, including all kinds of primitive arrays, buffers, CharSequence and more.

Written for Java 8+ under Apache 2.0 licence.

The key difference compared to other similar projects, e.g. Guava hashing, is that this has no object allocation during the hash computation and does not use ThreadLocal.

The implementation utilises native access where possible, but is also platform-endianness-agnostic. This provides consistent results whatever the byte order, while only moderately affecting performance.

Currently long-valued hash function interface is defined for 64-bit hash, and long[]-valued hash function interface for more than 64-bit hash, with the following implementations (in alphabetical order):

  • CityHash, version 1.1 (latest; 1.1.1 is a C++ language-specific maintenance release).

  • Two algorithms from FarmHash: farmhashna (introduced in FarmHash 1.0) and farmhashuo (introduced in FarmHash 1.1).

  • MetroHash (using the metrohash64_2 initialization vector).

  • MurmurHash3 128-bit and low 64-bit.

  • wyHash, version 3.

  • xxHash.

  • xxh3, xxh128, 128-bit and 64 bit.

These are thoroughly tested with LTS JDKs 8, 11, 17, and 21, plus the latest non-LTS JDKs on both little- and big-endian platforms. Other non-LTS JDKs from 9 should also work, but they will not be tested from half a year after EOL.

Performance

Tested on Intel Core i7-4870HQ CPU @ 2.50GHz

Algorithm Speed, GB/s Bootstrap, ns

xxHash

9.5

6

FarmHash na

9.0

6

FarmHash uo

7.2

7

CityHash

7.0

7

MurmurHash

5.3

12

MetroHash

??

??

WyHash

??

??

To sum up,

When to use Zero-Allocation Hashing

  • You need to hash plain byte sequences, memory blocks or "flat" objects.

  • You want zero-allocation and good performance (at Java scale).

  • You need hashing to be agile with regards to byte ordering.

When not to use Zero-Allocation Hashing

  • You need to hash POJOs whose actual data is scattered in memory between managed objects. There is no simple way to hash these using this project, for example, classes such as:

        class Person {
            String givenName, surName;
            int salary;
        }
  • You need to hash byte sequences of unknown length, for the simplest example, Iterator<Byte>.

  • You need to transform the byte sequence (e.g. encode or decode it with a specific coding), and hash the resulting byte sequence on the way without dumping it to memory.

Javadoc

See http://javadoc.io/doc/net.openhft/zero-allocation-hashing/latest

Internal documentation

  • Requirements overview

  • Architecture overview

  • Invariants and contracts

  • Algorithm profiles

  • Testing strategy

  • Performance benchmarks

  • Unsafe and platform notes

  • Change-log template

Quick start

Gradle:

dependencies {
    implementation 'net.openhft:zero-allocation-hashing:0.27ea1'
}

Or Maven:

<dependency>
  <groupId>net.openhft</groupId>
  <artifactId>zero-allocation-hashing</artifactId>
  <version>0.27ea1</version>
</dependency>

In Java:

long hash = LongHashFunction.wy_3().hashChars("hello");

See JavaDocs for more information.

Contributions are most welcome!

See the list of open issues.

About

Zero-allocation hashing for Java

Topics

cityhashfarmhashhash-functionshashinghigh-performancejavamurmurhash3openhftxxhash

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

849 stars

Watchers

49 watching

Forks

140 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.