Skip to main content
QUICK REVIEW

[Paper Review] PtrHash: Minimal Perfect Hashing at RAM Throughput

Ragnar Groot Koerkamp|arXiv (Cornell University)|Jan 1, 2025
Advanced Image and Video Retrieval TechniquesComputer Science1 citations
TL;DR

PtrHash introduces a minimal perfect hash function optimized for maximum query throughput and fast construction, using fixed-width 8-bit pilots, Cuckoo hashing-inspired pilot selection, and a single remap table encoded via per-cacheline Elias-Fano coding. It achieves up to 8 ns per key for integer keys—approaching the theoretical memory bandwidth limit—while being over 3× faster than the next-fastest method when streaming queries.

ABSTRACT

Given a set $K$ of $n$ keys, a minimal perfect hash function (MPHF) is a collision-free bijective map $\mathsf{H_{mphf}}$ from $K$ to $\{0, \dots, n-1\}$. This work presents a (minimal) perfect hash function that first prioritizes query throughput, while also allowing efficient construction for $10^9$ or more elements using 2.4 bits of memory per key. Both PTHash and PHOBIC first map all $n$ keys to $n/λ< n$ buckets. Then, each bucket stores a pilot that controls the final hash value of the keys mapping to it. PtrHash builds on this by using 1) fixed-width (uncompressed) 8-bit pilots, 2) a construction algorithm similar to cuckoo-hashing to find suitable pilot values. Further, it 3) uses the same number of buckets and slots for each part, with 4) a single remap table to map intermediate positions $\geq n$ to $

Motivation & Objective

  • Optimize minimal perfect hashing for maximum query throughput, especially for high-volume lookups in applications like bioinformatics and databases.
  • Address the performance bottleneck of existing MPHFs that require multiple memory accesses per query, especially for large-scale key sets.
  • Enable fast construction and low-latency streaming queries while maintaining space usage under 3 bits per key.
  • Improve upon PTHash and PHOBIC by simplifying data structure layout and reducing memory access overhead.

Proposed method

  • Uses fixed-width 8-bit pilots for each bucket, eliminating variable-length encoding and simplifying lookup logic.
  • Applies a Cuckoo hashing-inspired eviction strategy to resolve pilot conflicts during construction, ensuring collision-free assignment.
  • Partitions keys into fixed-size parts, each with its own set of buckets and slots, enabling independent and predictable memory layout.
  • Employs a single remap table using per-cacheline Elias-Fano (CacheLineEF) coding to map out-of-range hash values back into [0, n-1].
  • Supports streaming query processing via hardware prefetching, reducing effective latency by overlapping memory access with computation.
  • Uses a unified construction pipeline that balances load across parts and leverages cache-friendly memory access patterns.

Experimental results

Research questions

  • RQ1Can a minimal perfect hash function be designed to achieve near-peak memory bandwidth throughput for key lookups?
  • RQ2How can pilot selection and bucket assignment be simplified to reduce memory access overhead while maintaining collision-free hashing?
  • RQ3To what extent can streaming query processing and prefetching improve throughput in high-volume lookup workloads?
  • RQ4What is the trade-off between space efficiency and query speed when using fixed-width pilots and simplified remapping?

Key findings

  • With default parameters, PtrHash uses only 2.4 bits per key and is over 3.3× faster to query than the next-fastest method when processing streams of lookups.
  • For 10^9 integer keys, PtrHash achieves a query throughput of 8 ns per key using streaming, approaching the theoretical limit of 7.4 ns per cache line.
  • PtrHash is 2.1× faster to query than PTHash-HEM and 6.5× faster to construct, even while using slightly more space (2.4 bits/key).
  • The compact configuration of PtrHash uses 2.12 bits/key and is over 3× faster to construct than PHOBIC, with only slightly slower queries.
  • For string keys, query throughput drops to 23 ns/key with streaming, but remains significantly faster than alternatives due to optimized memory access patterns.
  • PtrHash saturates DDR4 memory bandwidth in multi-threaded settings, demonstrating its ability to scale with system memory limits.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.