assembly-hashmap 0.1.0

A single-threaded u64→u64 hashmap with x86-64 assembly operations and Rust-side growth.
Documentation
  • Coverage
  • 61.9%
    13 out of 21 items documented1 out of 20 items with examples
  • Size
  • Source code size: 80.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 365.4 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gagan405

assembly-hashmap

Single-threaded u64 → u64 hashmap. Table operations run in x86-64 assembly (SwissTable / SIMD control bytes). Growth, allocation, and migration stay in Rust. On non-x86-64 targets the crate falls back to a C reference of the same algorithm.

[dependencies]
assembly-hashmap = "0.1"

A C compiler (cc / clang) is required at build time.

Use

use assembly_hashmap::AssemblyHashMap;

fn main() {
    let mut map = AssemblyHashMap::new();
    map.put(1, 10);
    assert_eq!(map.get(1), Some(10));
    assert_eq!(map.remove(1), Some(10));
}

See examples/basic.rs for the rest of the API (put_if_absent, get_or_insert, replace, iter, reserve).

The map is !Send / !Sync. Operations match std::collections::HashMap for u64 keys except that the hasher is fixed (FxHash-style multiply) and the table is not concurrent.

Examples

cargo run --example basic

Tests

cargo test

On a non-x86-64 host this tests the C fallback. To exercise native/hashmap.S:

make rust-docker-test

Benchmarks

Replay the same put/get stream against this map and std::collections::HashMap:

cargo run --release --example bench

Meaningful numbers need native x86-64. Override workload size:

HM_BENCH_KEYS=1048576 \
HM_BENCH_OPS=16777216 \
HM_BENCH_ROUNDS=10 \
cargo run --release --example bench
Variable Default Meaning
HM_BENCH_KEYS 1 << 18 insertion key space
HM_BENCH_OPS 1 << 21 operations in the timed stream
HM_BENCH_ROUNDS 5 timed repeats; best time is reported

The example first checks that both maps produce identical results, then times each independently. The printed backend line is x86-64 hashmap.S when the assembly path is linked.