HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm

Flajolet, Fusy, Gandouet, Meunier, 2007

Read the paper19 min video

The solution introduced in [15] under the name of stochastic averaging, consists in emulating the effect of m experiments with a single hash function.”
Flajolet, Fusy, Gandouet and Meunier, 2007

Included with any plan

Watch with a plan

Any plan opens this 19 min video and the full write-up, plus every paper in the library and every course.

A page has been visited all day. Redis has a key called visitors:home:today. Each visit runs PFADD with the visitor's ID, and PFCOUNT gives an approximate number of different visitors. Redis's documented dense counter uses 12,288 bytes of register data, whether the day has a few thousand visitors or millions. How can a counter answer without keeping their IDs?

The PF at the front of those commands is there in honour of Philippe Flajolet, the paper's first author. The answer is to remember a property of each ID's hash, not the ID itself. A rare bit pattern suggests how many different hashes have passed by. HyperLogLog repeats that small experiment across many registers and combines their guesses carefully.

HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm
Philippe Flajolet, Éric Fusy, Olivier Gandouet, Frédéric Meunier · 2007
Open original

This paper is hosted by its original publisher.

Read on dmtcs.episciences.org

The Problem in 2007

Flajolet, Fusy, Gandouet, and Meunier wrote for the 2007 Conference on Analysis of Algorithms. Their example is network traffic: a packet header has a source and destination address, and the number of different address pairs in a time slice helps reveal active flows. The same pair may appear many times. Cardinality means the number of distinct pairs, not the number of packets.

An exact set must remember each different item, so its memory grows with the answer. Their target is a massive stream read once, where a small, known estimation error is acceptable. They analyze a counter that updates one tiny part of its state per item and needs no stored IDs.

The preview ends here

Keep reading with a plan

9 more sections and the full video. Any plan opens them, every other paper in the library, and every course.