Java Clean Architecture Masterclass

Java Clean Architecture Masterclass28-29 May

Join

HashSmith: Fast & memory efficient hash tables for Java

License: MIT Maven Central javadoc Status: experimental

HashSmith logo

Overview

Implementations

Why SWAR by default?

Vector API is still incubating, and profiling on my setup showed the SIMD path taking longer than expected, so the default SwissMap favors a SWAR probe. Numbers can differ significantly by hardware/JVM version; please run your own benchmarks if you plan to use SwissSimdMap.

Blog / Write-up

Quick Start

import io.github.bluuewhale.hashsmith.SwissMap;      // SWAR
import io.github.bluuewhale.hashsmith.ConcurrentSwissMap;
import io.github.bluuewhale.hashsmith.SwissSet;

// SwissMap (SWAR)
var swiss = new SwissMap<String, Integer>();
swiss.put("a", 1);
swiss.get("a"); // 1

// ConcurrentSwissMap (sharded, thread-safe)
var concurrentSwiss = new ConcurrentSwissMap<String, Integer>();
concurrentSwiss.put("a", 1);
concurrentSwiss.get("a"); // 1

// SwissSet
var swissSet = new SwissSet<String>();
swissSet.add("k");
swissSet.add(null); // nulls allowed
swissSet.contains("k"); // true

Install

dependencies {
    implementation("io.github.bluuewhale:hashsmith:0.1.8")
}
dependencies {
    implementation 'io.github.bluuewhale:hashsmith:0.1.8'
}
<dependency>
  <groupId>io.github.bluuewhale</groupId>
  <artifactId>hashsmith</artifactId>
  <version>0.1.8</version>
</dependency>

Requirements

Build & Test

./gradlew build        # full build
./gradlew test         # JUnit 5 tests

Memory Footprint

Results

Map Set
HashMap Memory Footprint HashSet Memory Footprint

Benchmark (JMH, CPU ns/op)

put hit put miss
CPU: put hit CPU: put miss
get hit get miss
CPU: get hit CPU: get miss

Contributing

  1. Open an issue for bugs/ideas
  2. Work on a feature branch and open a PR
  3. Keep tests/JMH green before submitting

License

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.