A system that counts every distinct item in a long stream needs a place to keep every count. That is an awkward requirement when the number of different items is large or unknown. Graham Cormode and S. Muthukrishnan proposed keeping a compact summary instead. Their Count-Min Sketch uses several rows of counters. Each row has its own hash function. When an item arrives with a nonnegative increment, the sketch adds that increment to the counter selected in each row. To estimate the count for a known item, it checks the same counters and takes the smallest value. The construction was published in the Journal of Algorithms in April 2005. The name describes the operation: look up the counts and take their minimum. [1] [2]
The result is a way to answer a point query without retaining a separate entry for every key. Each item still updates several counters, but the size of the counter array is chosen in advance. Collisions mean other items can contribute to the counters queried. With nonnegative updates, every queried counter includes the item's full contribution, so the estimate cannot fall below the true count. The original theorem bounds the size of the overestimate with a chosen probability. The error term is proportional to the total weight of the stream, not to the frequency of the individual item. That distinction is especially important for rare items in a large stream. [2] [3]
The minimum helps because a single crowded counter need not determine the result. Different hash functions give an item different groups of neighbors across the rows. If at least one row has few collisions for the queried item, the minimum selects the smaller amount of extra weight. More counters across each row reduce collisions, while more rows reduce the chance that all rows give a poor estimate. The trade is simple to use but has limits: the summary does not keep the list of keys, and an apparent hit near a threshold may be a collision. The one-sided claim here applies to the nonnegative setting described by the original proof. It should not be copied unchanged into a system with arbitrary negative counts. [2] [3]
Analysis & application
Before using the sketch, decide how much overcount the downstream decision can tolerate. If a system only needs to nominate busy keys for further inspection, use the sketch to nominate them and maintain an exact count for the shortlisted keys. If a decision triggers a costly action, verify the exact count first. Replay a small slice of real traffic against an exact map. Check both common keys and rare keys under realistic skew, and compare memory usage, update cost and the number of false alerts. Run the comparison through a traffic spike, when total weight and collisions change. Record the reset or expiry policy. A counter that covers a full day cannot be interpreted as a count for the last minute simply because the dashboard is refreshed once a minute.
A separate team at the 2005 Internet Measurement Conference used Count-Min as a comparison when studying estimates of network traffic. Its paper reports better reconstruction from a least-squares approach in its experiments, with different query work and assumptions. This illustrates why the original bound does not choose the best method for every workload. An application that needs fast approximate lookups for known keys has different requirements from one that needs the most precise possible recovery of a group of large flows. The case is useful because it makes that design choice explicit: use a fixed budget of memory and accept a predictable kind of error, then use a more expensive measurement only where the decision needs it. [2] [3]
FOLLOW THE EVIDENCE
The sources
- An improved data stream summary: The Count-Min Sketch and its applications Graham Cormode / University of Oxford · cs.ox.ac.uk
- An improved data stream summary: The Count-Min Sketch and its applications Journal of Algorithms, hosted by Aarhus University · cs.au.dk
- Improving Sketch Reconstruction Accuracy Using Linear Least Squares Method USENIX Internet Measurement Conference · static.usenix.org