PTHash: Revisiting FCH Minimal Perfect Hashing

Giulio Ermanno Pibiri, Roberto Trani
4/21/2021
60 citations
cs.DS

Official code: jermp/pthash (270 stars, C++, MIT, last commit 2026-07-27). 1 more implementation below.

Abstract

Given a set $S$ of $n$ distinct keys, a function $f$ that bijectively maps the keys of $S$ into the range $\{0,\ldots,n-1\}$ is called a minimal perfect hash function for $S$. Algorithms that find such functions when $n$ is large and retain constant evaluation time are of practical interest; for instance, search engines and databases typically use minimal perfect hash functions to quickly assign identifiers to static sets of variable-length keys such as strings.

Show full abstract

The challenge is to design an algorithm which is efficient in three different aspects: time to find $f$ (construction time), time to evaluate $f$ on a key of $S$ (lookup time), and space of representation for $f$. Several algorithms have been proposed to trade-off between these aspects. In 1992, Fox, Chen, and Heath (FCH) presented an algorithm at SIGIR providing very fast lookup evaluation. However, the approach received little attention because of its large construction time and higher space consumption compared to other subsequent techniques. Almost thirty years later we revisit their framework and present an improved algorithm that scales well to large sets and reduces space consumption altogether, without compromising the lookup time. We conduct an extensive experimental assessment and show that the algorithm finds functions that are competitive in space with state-of-the art techniques and provide $2-4\times$ better lookup time.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
jermp/pthashOfficial270C++MIT2026-07-27
roberto-trani/mphf_benchmarkOfficial40C++MIT2022-12-20
jermp/pthashOfficial100%
MIT

✈️ PTHash is a fast and compact minimal perfect hash function.

27038C++, PythonApr 21, 20214 months agoMIT
hashhash-functionhashingminimal-perfect-hash
MIT

A Benchmark of Minimal Perfect Hash Function Algorithms.

403C++, CMakeApr 15, 20213 years agoMIT

Similar Papers

Cite this paper

@article{pibiri2021pthash,
  title  = {PTHash: Revisiting FCH Minimal Perfect Hashing},
  author = {Giulio Ermanno Pibiri and Roberto Trani},
  year   = {2021},
  eprint = {2104.10402},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2104.10402}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2104.10402.svg)](https://codeofpaper.com/paper/2104.10402)

Discussion