Hashing and Packet Level Algorithms

Slides:



Advertisements
Similar presentations
Why Simple Hash Functions Work : Exploiting the Entropy in a Data Stream Michael Mitzenmacher Salil Vadhan And improvements with Kai-Min Chung.
Advertisements

Multiple Choice Hash Tables with Moves on Deletes and Inserts Adam Kirsch Michael Mitzenmacher.
3/13/2012Data Streams: Lecture 161 CS 410/510 Data Streams Lecture 16: Data-Stream Sampling: Basic Techniques and Results Kristin Tufte, David Maier.
Why Simple Hash Functions Work : Exploiting the Entropy in a Data Stream Michael Mitzenmacher Salil Vadhan.
Hash-based Indexes CS 186, Spring 2006 Lecture 7 R &G Chapter 11 HASH, x. There is no definition for this word -- nobody knows what hash is. Ambrose Bierce,
1 Hash-Based Indexes Module 4, Lecture 3. 2 Introduction As for any index, 3 alternatives for data entries k* : – Data record with key value k – –Choice.
Hash-Based Indexes The slides for this text are organized into chapters. This lecture covers Chapter 10. Chapter 1: Introduction to Database Systems Chapter.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Hash-Based Indexes Chapter 11.
Quick Review of Apr 10 material B+-Tree File Organization –similar to B+-tree index –leaf nodes store records, not pointers to records stored in an original.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Hash-Based Indexes Chapter 11.
Chapter 11 Indexing and Hashing (2) Yonsei University 2 nd Semester, 2013 Sanghyun Park.
Chapter 11 (3 rd Edition) Hash-Based Indexes Xuemin COMP9315: Database Systems Implementation.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
File Processing - Indirect Address Translation MVNC1 Hashing Indirect Address Translation Chapter 11.
Cuckoo Filter: Practically Better Than Bloom
Optimal Fast Hashing Yossi Kanizo (Technion, Israel) Joint work with Isaac Keslassy (Technion, Israel) and David Hay (Hebrew Univ., Israel)
1 Hashing, randomness and dictionaries Rasmus Pagh PhD defense October 11, 2002.
Searching Kruse and Ryba Ch and 9.6. Problem: Search We are given a list of records. Each record has an associated key. Give efficient algorithm.
An Improved Construction for Counting Bloom Filters Flavio Bonomi Michael Mitzenmacher Rina Panigrahy Sushil Singh George Varghese Presented by: Sailesh.
Cuckoo Hashing : Hardware Implementations Adam Kirsch Michael Mitzenmacher.
Beyond Bloom Filters: Approximate Concurrent State Machines Michael Mitzenmacher Joint work with Flavio Bonomi, Rina Panigrahy, Sushil Singh, George Varghese.
CSC1016 Coursework Clarification Derek Mortimer March 2010.
Bloom Filters Kira Radinsky Slides based on material from:
Data Structures Hash Tables
1 Hash-Based Indexes Yanlei Diao UMass Amherst Feb 22, 2006 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Hash Tables With Finite Buckets Are Less Resistant to Deletions Yossi Kanizo (Technion, Israel) Joint work with David Hay (Columbia U. and Hebrew U.) and.
Fast Statistical Spam Filter by Approximate Classifications Authors: Kang Li Zhenyu Zhong University of Georgia Reader: Deke Guo.
Why Simple Hash Functions Work : Exploiting the Entropy in a Data Stream Michael Mitzenmacher Salil Vadhan.
Beyond Bloom Filters: From Approximate Membership Checks to Approximate State Machines By F. Bonomi et al. Presented by Kenny Cheng, Tonny Mak Yui Kuen.
Cuckoo Hashing and CAMs Michael Mitzenmacher. Background For the past several years, I have had funding from Cisco to research hash tables and related.
Packet Level Algorithms Michael Mitzenmacher. Goals of the Talk Consider algorithms/data structures for measurement/monitoring schemes at the router level.
Tirgul 8 Universal Hashing Remarks on Programming Exercise 1 Solution to question 2 in theoretical homework 2.
FALL 2004CENG 3511 Hashing Reference: Chapters: 11,12.
Advanced Algorithms for Massive Datasets Basics of Hashing.
Optimal Fast Hashing Yossi Kanizo (Technion, Israel) Joint work with Isaac Keslassy (Technion, Israel) and David Hay (Politecnico di Torino, Italy)
Tirgul 7. Find an efficient implementation of a dynamic collection of elements with unique keys Supported Operations: Insert, Search and Delete. The keys.
1Bloom Filters Lookup questions: Does item “ x ” exist in a set or multiset? Data set may be very big or expensive to access. Filter lookup questions with.
Hash, Don’t Cache: Fast Packet Forwarding for Enterprise Edge Routers Minlan Yu Princeton University Joint work with Jennifer.
Data Structures Hashing Uri Zwick January 2014.
1. 2 Problem RT&T is a large phone company, and they want to provide enhanced caller ID capability: –given a phone number, return the caller’s name –phone.
Cloud and Big Data Summer School, Stockholm, Aug., 2015 Jeffrey D. Ullman.
Fast and deterministic hash table lookup using discriminative bloom filters  Author: Kun Huang, Gaogang Xie,  Publisher: 2013 ELSEVIER Journal of Network.
CS212: DATA STRUCTURES Lecture 10:Hashing 1. Outline 2  Map Abstract Data type  Map Abstract Data type methods  What is hash  Hash tables  Bucket.
Compact Data Structures and Applications Gil Einziger and Roy Friedman Technion, Haifa.
Today  Table/List operations  Parallel Arrays  Efficiency and Big ‘O’  Searching.
Author: Haoyu Song, Fang Hao, Murali Kodialam, T.V. Lakshman Publisher: IEEE INFOCOM 2009 Presenter: Chin-Chung Pan Date: 2009/12/09.
March 16 & 21, Csci 2111: Data and File Structures Week 9, Lectures 1 & 2 Indexed Sequential File Access and Prefix B+ Trees.
Hashing Chapter 20. Hash Table A hash table is a data structure that allows fast find, insert, and delete operations (most of the time). The simplest.
1 CSE 326: Data Structures: Hash Tables Lecture 12: Monday, Feb 3, 2003.
A Formal Analysis of Conservative Update Based Approximate Counting Gil Einziger and Roy Freidman Technion, Haifa.
Hashing Sections 10.2 – 10.3 CS 302 Dr. George Bebis.
Can’t provide fast insertion/removal and fast lookup at the same time Vectors, Linked Lists, Stack, Queues, Deques 4 Data Structures - CSCI 102 Copyright.
Hashing 8 April Example Consider a situation where we want to make a list of records for students currently doing the BSU CS degree, with each.
Ihab Mohammed and Safaa Alwajidi. Introduction Hash tables are dictionary structure that store objects with keys and provide very fast access. Hash table.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Hash-Based Indexes Chapter 11 Modified by Donghui Zhang Jan 30, 2006.
Introduction to Database, Fall 2004/Melikyan1 Hash-Based Indexes Chapter 10.
1.1 CS220 Database Systems Indexing: Hashing Slides courtesy G. Kollios Boston University via UC Berkeley.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Indexed Sequential Access Method.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Hash-Based Indexes Chapter 10.
Sorting: Implementation Fundamental Data Structures and Algorithms Klaus Sutner February 24, 2004.
Hash Table March COP 3502, UCF 1. Outline Hash Table: – Motivation – Direct Access Table – Hash Table Solutions for Collision Problem: – Open.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables IV.
Cuckoo Filter: Practically Better Than Bloom Author: Bin Fan, David G. Andersen, Michael Kaminsky, Michael D. Mitzenmacher Publisher: ACM CoNEXT 2014 Presenter:
CSC 143T 1 CSC 143 Highlights of Tables and Hashing [Chapter 11 p (Tables)] [Chapter 12 p (Hashing)]
Hash-Based Indexes Chapter 11
Hash-Based Indexes Chapter 11
Database Design and Programming
EMOMA- Exact Match in One Memory Access
Hash Functions for Network Applications (II)
Presentation transcript:

Hashing and Packet Level Algorithms Michael Mitzenmacher

Goals of the Talk Consider algorithms/data structures for measurement/monitoring schemes at the router level. Focus on packets, flows. Emphasis on my recent work, future plans. “Applied theory”. Less on experiments, more on design/analysis of data structures for applications. Hash-based schemes Bloom filters and variants.

Vision Three-pronged research data. Low: Efficient hardware implementations of relevant algorithms and data structures. Medium: New, improved data structures and algorithms for old and new applications. High: Distributed infrastructure supporting monitoring and measurement schemes.

Background / Building Blocks Multiple-choice hashing Bloom filters

Multiple Choices: d-left Hashing Split hash table into d equal subtables. To insert, choose a bucket uniformly for each subtable. Place item in a cell in the least loaded bucket, breaking ties to the left.

Properties of d-left Hashing Analyzable using both combinatorial methods and differential equations. Maximum load very small: O(log log n). Differential equations give very, very accurate performance estimates. Maximum load is extremely close to average load for small values of d.

Example of d-left hashing Consider 3-left performance. Average load 6.4 Average load 4 Load 0 1.7e-08 Load 1 5.6e-07 Load 2 1.2e-05 Load 3 2.1e-04 Load 4 3.5e-03 Load 5 5.6e-02 Load 6 4.8e-01 Load 7 4.5e-01 Load 8 6.2e-03 Load 9 4.8e-15 Load 0 2.3e-05 Load 1 6.0e-04 Load 2 1.1e-02 Load 3 1.5e-01 Load 4 6.6e-01 Load 5 1.8e-01 Load 6 Load 7 5.6e-31

Example of d-left hashing Consider 4-left performance with average load of 6, using differential equations. Alternating insertions/deletions Steady state Insertions only Load > 1 1.0000 Load > 2 Load > 3 Load > 4 0.9999 Load > 5 0.9971 Load > 6 0.8747 Load > 7 0.1283 Load > 8 1.273e-10 Load > 9 2.460e-138 Load > 1 1.0000 Load > 2 0.9999 Load > 3 0.9990 Load > 4 0.9920 Load > 5 0.9505 Load > 6 0.7669 Load > 7 0.2894 Load > 8 0.0023 Load > 9 1.681e-27

Review: Bloom Filters Given a set S = {x1,x2,x3,…xn} on a universe U, want to answer queries of the form: Bloom filter provides an answer in “Constant” time (time to hash). Small amount of space. But with some probability of being wrong. Alternative to hashing with interesting tradeoffs.

Bloom Filters B B B B Start with an m bit array, filled with 0s. B Hash each item xj in S k times. If Hi(xj) = a, set B[a] = 1. 1 B To check if y is in S, check B at Hi(y). All k values must be 1. 1 B Possible to have a false positive; all k values are 1, but y is not in S. 1 B n items m = cn bits k hash functions

False Positive Probability Pr(specific bit of filter is 0) is If r is fraction of 0 bits in the filter then false positive probability is Approximations valid as r is concentrated around E[r]. Martingale argument suffices. Find optimal at k = (ln 2)m/n by calculus. So optimal fpp is about (0.6185)m/n n items m = cn bits k hash functions

Example m/n = 8 Opt k = 8 ln 2 = 5.45... n items m = cn bits k hash functions

Handling Deletions Bloom filters can handle insertions, but not deletions. If deleting xi means resetting 1s to 0s, then deleting xi will “delete” xj. xi xj B 1 1 1 1 1 1 1 1

Counting Bloom Filters Start with an m bit array, filled with 0s. B Hash each item xj in S k times. If Hi(xj) = a, add 1 to B[a]. 3 1 2 B To delete xj decrement the corresponding counters. 2 3 1 B Can obtain a corresponding Bloom filter by reducing to 0/1. 1 B

Counting Bloom Filters: Overflow Must choose counters large enough to avoid overflow. Poisson approximation suggests 4 bits/counter. Average load using k = (ln 2)m/n counters is ln 2. Probability a counter has load at least 16: Failsafes possible. We assume 4 bits/counter for comparisons.

Bloomier Filters Instead of set membership, keep an r-bit function value for each set element. Correct value should be given for each set element. Non-set elements should return NULL with high probability. Mutable version: function values can change. But underlying set can not. First suggested in paper by Chazelle, Kilian, Rubenfeld, Tal.

From Low to High Low Medium High Hash Tables for Hardware New Bloom Filter/Counting Bloom Filter Constructions (Hardware Friendly) Medium Approximate Concurrent State Machines High A Distributed Hashing Infrastructure Why do Weak Hash Functions Work So Well?

Low Level : Better Hash Tables for Hardware Joint work with Adam Kirsch. Simple Summaries for Hashing with Choices. The Power of One Move: Hashing Schemes for Hardware.

Perfect Hashing Approach Element 1 Element 2 Element 3 Element 4 Element 5 Fingerprint(4) Fingerprint(5) Fingerprint(2) Fingerprint(1) Fingerprint(3)

Near-Perfect Hash Functions Perfect hash functions are challenging. Require all the data up front – no insertions or deletions. Hard to find efficiently in hardware. In [BM96], we note that d-left hashing can give near-perfect hash functions. Useful even with insertions, deletions. Some loss in space efficiency.

Near-Perfect Hash Functions via d-left Hashing Maximum load equals 1 Requires significant space to avoid all collisions, or some small fraction of spillovers. Maximum load greater than 1 Multiple buckets must be checked, and multiple cells in a bucket must be checked. Not perfect in space usage. In practice, 75% space usage is very easy. In theory, can do even better.

Hash Table Design : Example Desired goals: At most 1 item per bucket. Minimize space. And minimize number of hash functions. Small amount of spillover possible. We model as a constant fraction, e.g. 0.2%. Can be placed in a content-addressable memory (CAM) if small enough.

Basic d-left Scheme For hash table holding up to n elements, with max load 1 per bucket, use 4 choices and 2n cells. Spillover of approximately 0.002n elements into CAM.

Improvements from Skew For hash table holding up to n elements, with max load 1 per bucket, use 4 choices and 1.8n cells. Subtable sizes 0.79n, 0.51n, 0.32n, 0.18n. Spillover still approximately 0.002n elements into CAM. Subtable sizes optimized using differential equations, black-box optimization. xk

Summaries to Avoid Lookups In hardware, d choices of location can be done by parallelization. Look at d memory banks in parallel. But there’s still a cost: pin count. Can we keep track of which hash function to use for each item, using a small summary? Yes: use a Bloom-filter like structure to track. Skew impacts summary performance; more skew better. Uses small amount of on-chip memory. Avoids multiple look-ups. Special case of a Bloomier filter.

Hash Tables with Moves Cuckoo Hashing (Pagh, Rodler) Hashed items need not stay in their initial place. With multiple choices, can move item to another choice, without affecting lookups. As long as hash values can be recomputed. When inserting, if all spots are filled, new item kicks out an old item, which looks for another spot, and might kick out another item, and so on.

Benefits and Problems of Moves Benefit: much better space utilization. Multiple choices, multiple items per bucket, can achieve 90+% with no spillover. Drawback: complexity. Moves required can grow like log n. Constant on average. Bounded maximum time per operation important in many settings. Moves expensive. Table usually in slow memory.

Question : Power of One Move How much leverage do we get by just allowing one move? One move likely to be possible in practice. Simple for hardware. Analysis possible via differential equations. Cuckoo hard to analyze. Downside : some spillover into CAM.

Comparison, Insertions Only 4 schemes No moves Conservative : Place item if possible. If not, try to move earliest item that has not already replaced another item to make room. Otherwise spill over. Second chance : Read all possible locations, and for each location with an item, check it it can be placed in the next subtable. Place new item as early as possible, moving up to 1 item left 1 level. Second chance, with 2 per bucket. Target of 0.2% spillover. Balanced (all subtables the same) and skewed compared. All done by differential equation analysis (and simulations match).

Results of Moves : Insertions Only Space overhead, balanced Space overhead, skewed Fraction moved, skewed No moves 2.00 1.79 0% Conservative 1.46 1.39 1.6% Standard 1.41 1.29 12.0% Standard, 2 1.14 1.06 14.9%

Conclusions, Moves Even one move saves significant space. More aggressive schemes, considering all possible single moves, save even more. (Harder to analyze, more hardware resources.) Importance of allowing small amounts of spillover in practical settings.

Future Work This analysis was for insertions only. Lots more space required in case of deletions. Different behavior in steady state. More moves may be required. Examining possible implementations. With Adam Kirsch, to appear in Allerton.

From Low to High Low Medium High Hash Tables for Hardware New Bloom Filter/Counting Bloom Filter Constructions (Hardware Friendly) Medium Approximate Concurrent State Machines High A Distributed Hashing Infrastructure Why do Weak Hash Functions Work So Well?

Low- Medium: New Bloom Filters / Counting Bloom Filters Joint work with Flavio Bonomi, Rina Panigrahy, Sushil Singh, George Varghese.

A New Approach to Bloom Filters Folklore Bloom filter construction. Recall: Given a set S = {x1,x2,x3,…xn} on a universe U, want to answer membership queries. Method: Find an n-cell perfect hash function for S. Maps set of n elements to n cells in a 1-1 manner. Then keep bit fingerprint of item in each cell. Lookups have false positive < e. Advantage: each bit/item reduces false positives by a factor of 1/2, vs ln 2 for a standard Bloom filter. Negatives: Perfect hash functions non-trivial to find. Cannot handle on-line insertions.

Near-Perfect Hash Functions In [BM96], we note that d-left hashing can give near-perfect hash functions. Useful even with deletions. Main differences Multiple buckets must be checked, and multiple cells in a bucket must be checked. Not perfect in space usage. In practice, 75% space usage is very easy. In theory, can do even better.

First Design : Just d-left Hashing For a Bloom filter with n elements, use a 3-left hash table with average load 4, 60 bits per bucket divided into 6 fixed-size fingerprints of 10 bits. Overflow rare, can be ignored. False positive rate of Vs. 0.000744 for a standard Bloom filter. Problem: Too much empty, wasted space. Other parametrizations similarly impractical. Need to avoid wasting space.

Just Hashing : Picture Empty Empty Bucket 0000111111 1010101000 0001110101 1011011100

Key: Dynamic Bit Reassignment Use 64-bit buckets: 4 bit counter, 60 bits divided equally among actual fingerprints. Fingerprint size depends on bucket load. False positive rate of 0.0008937 Vs. 0.0004587 for a standard Bloom filter. DBR: Within a factor of 2. And would be better for larger buckets. But 64 bits is a nice bucket size for hardware. Can we remove the cost of the counter?

DBR : Picture Bucket Count : 4 000110110101 111010100001 101010101000 101010110101 010101101011 Bucket Count : 4

Semi-Sorting Fingerprints in bucket can be in any order. Semi-sorting: keep sorted by first bit. Use counter to track #fingerprints and #fingerprints starting with 0. First bit can then be erased, implicitly given by counter info. Can extend to first two bits (or more) but added complexity.

DBR + Semi-sorting : Picture 000110110101 111010100001 101010101000 101010110101 010101101011 Bucket Count : 4,2

DBR + Semi-Sorting Results Using 64-bit buckets, 4 bit counter. Semi-sorting on loads 4 and 5. Counter only handles up to load 6. False positive rate of 0.0004477 Vs. 0.0004587 for a standard Bloom filter. This is the tradeoff point. Using 128-bit buckets, 8 bit counter, 3-left hash table with average load 6.4. Semi-sorting all loads: fpr of 0.00004529 2 bit semi-sorting for loads 6/7: fpr of 0.00002425 Vs. 0.00006713 for a standard Bloom filter.

Additional Issues Futher possible improvements Group buckets to form super-buckets that share bits. Conjecture: Most further improvements are not worth it in terms of implementation cost. Moving items for better balance? Underloaded case. New structure maintains good performance.

Improvements to Counting Bloom Filter Similar ideas can be used to develop an improved Counting Bloom Filter structure. Same idea: use fingerprints and a d-left hash table. Counting Bloom Filters waste lots of space. Lots of bits to record counts of 0. Our structure beats standard CBFs easily, by factors of 2 or more in space. Even without dynamic bit reassignment.

From Low to High Low Medium High Hash Tables for Hardware New Bloom Filter/Counting Bloom Filter Constructions (Hardware Friendly) Medium Approximate Concurrent State Machines High A Distributed Hashing Infrastructure Why do Weak Hash Functions Work So Well?

Approximate Concurrent State Machines Joint work with Flavio Bonomi, Rina Panigrahy, Sushil Singh, George Varghese. Extending the Bloomier filter idea to handle dynamic sets, dynamic function values, in practical setting.

Approximate Concurrent State Machines Model for ACSMs We have underlying state machine, states 1…X. Lots of concurrent flows. Want to track state per flow. Dynamic: Need to insert new flows and delete terminating flows. Can allow some errors. Space, hardware-level simplicity are key.

Motivation: Router State Problem Suppose each flow has a state to be tracked. Applications: Intrusion detection Quality of service Distinguishing P2P traffic Video congestion control Potentially, lots of others! Want to track state for each flow. But compactly; routers have small space. Flow IDs can be ~100 bits. Can’t keep a big lookup table for hundreds of thousands or millions of flows!

Problems to Be Dealt With Keeping state values with small space, small probability of errors. Handling deletions. Graceful reaction to adversarial/erroneous behavior. Invalid transitions. Non-terminating flows. Could fill structure if not eventually removed. Useful to consider data structures in well-behaved systems and ill-behaved systems.

Summary We have an ACSM design. ACSM performance seems reasonable: Similar to new Bloom filter design. ACSM design came first! ACSM performance seems reasonable: Sub 1% error rates with reasonable size.

From Low to High Low Medium High Hash Tables for Hardware New Bloom Filter/Counting Bloom Filter Constructions (Hardware Friendly) Medium Approximate Concurrent State Machines High A Distributed Hashing Infrastructure Why do Weak Hash Functions Work So Well?

A Distributed Router Infrastructure Recently funded FIND proposal. Looking for ideas/collaborators.

The High-Level Pitch Lots of hash-based schemes being designed for approximate measurement/monitoring tasks. But not built into the system to begin with. Want a flexible router architecture that allows: New methods to be easily added. Distributed cooperation using such schemes.

What We Need Off-Chip Memory On-Chip Memory CAM(s) Memory Hashing Computation Unit Unit for Other Computation Programming Language Computation Control System Communication Architecture Communication + Control

Lots of Design Questions How much space for various memory levels? How can we dynamically divide memory among multiple competing applications? What hash functions should be included? How open should system be to new hash functions? What programming functionality should be included? What programming language to use? What communication is necessary to achieve distributed monitoring tasks given the architecture? Should security be a consideration? What security approaches are possible? And so on…

Which Hash Functions? Theorists: Practitioners: Want hash functions with analyzable properties. Dislike assuming fully random hash functions. Which we have done! But often what you can prove doesn’t match actual performance. Practitioners: Want easily implementable, fast hash functions. Space and speed important! Want simple analysis. Generally accept simulated behavior. But possible danger!!!

Why Do Weak Hash Functions Work So Well? In reality, assuming perfectly random hash functions seems to be the right thing to do. Easier to analyze. Real systems almost always work that way, even with weak hash functions! Can Theory explain strong performance of weak hash functions?

Recent Work A new explanation: Joint work with Salil Vadhan. Choosing a hash function from a pairwise independent family is enough – if data has sufficient entropy. Randomness of hash function and data “combine”. Behavior matches truly random hash function with high probability. Techniques based on theory of randomness extraction. Leftover Hash Lemma, extensions.

Sample Results and Implications Consider input data of n items as a stream, {X1,X2,…,Xn} of random variables. Let collision probability Suppose , is close to that of a uniform distribution. Then hashed data is close to uniform. Implications: for d-left hashing, Bloom filters, linear hashing, etc. choosing a hash function from a pairwise independent family should behave like the perfect analysis, if the data has enough entropy.

Conclusions and Future Work Low: Mapping current hashing techniques to hardware is fruitful for practice. Medium: Big boom in hashing-based algorithms/data structures. Trend is likely to continue. Approximate concurrent state machines: Natural progression from set membership to functions (Bloomier filter) to state machines. What is next? Power of d-left hashing variants for near-perfect matchings. High: Wide open. Need to systematize our knowledge for next generation systems. Measurement and monitoring infrastructure built into the system.