Understanding Bloom Filter Intersection for Lazy AddressSet Disambiguation
Understanding Bloom Filter Intersection for Lazy Address-Set Disambiguation Mark Jeffrey and J. Gregory Steffan ECE, University of Toronto June 6, 2011
Parallel Programming is Hard T 1 Rd(a) Rd(b) Wr(a) T 2 Rd(a) T 3 Wr(c) Rd(x) Rd(a) Tools offload some burden of managing data accesses: – Memory Race Replay – Atomicity Violation Survival – Transactional Memory – Speculative Optimizations Many tools are using Bloom filters Mark Jeffrey and Greg Steffan, U of Toronto 2
& Bloom Filter • Bit-vector-based data structure [1970] – offers fast set operations – in exchange for some imprecision • Recently used to compare memory accesses • With unconventional practices: Intersection • We show new practices are inefficient! (in theory) Mark Jeffrey and Greg Steffan, U of Toronto 3
Bloom Filters in Concurrency Tools We provide. Year new theory to guide tool designers! System Application Bulk 2006 Hardware TM Bulk. SC 2007 Memory Consistency HARD 2007 Race Detection De. Lorean 2008 Deterministic Race Replay Soft. Sig 2008 Code Analysis/Optimization/Debug Ring. STM 2008 Software TM Fast. Path 2009 Software TM (or TLS) Sig. Race 2009 Race Detection Color. Safe 2010 Atomicity Violation Inval. STM 2010 Software TM Adap. Sig 2010 Software TM Mark Jeffrey and Greg Steffan, U of Toronto 4
Tracking Address-Set Conflicts Mark Jeffrey and Greg Steffan, U of Toronto 5
Address-Sets T 1 T 2 a Rd(b) b Rd(a) T 3 Wr(c) Rd(x) Wr(a) Rd(a) Read Set: • memory locations read • RT 1 = { , } Rd(a) Write Set: • memory locations written • WT 1 = {a} Mark Jeffrey and Greg Steffan, U of Toronto 6
Burden: Address-Set Conflicts T 1 Conflicts T 2 Rd(a) T 3 Rd(b) Wr(c) Rd(x) Wr(a) Rd(a) – address accesses are dependent – independence -> parallelism! – address conflicts -> no parallelism Conflict Detection requires – read and write set comparison – runtime address disambiguation Mark Jeffrey and Greg Steffan, U of Toronto 7
Conflict Detection – When? • Eager – Detect conflicts at the time of memory access Thread 1 Wr(b)- Thread 2 -Rd(a) Wr‘b’ OK? • Lazy – Detect conflicts at the end of an arbitrary epoch Thread 1 Rd(a)Wr(b)Rd(c)Mark Jeffrey and Greg Steffan, U of Toronto Thread 2 -Rd(a) -Rd(b) {a, b, c} OK? 8
Conflict Detection – When? • Eager = Set Membership – Query for that single address in the access sets Thread 1 Wr(b)- Thread 2 -Rd(a) • Lazy = Set Overlap – Compare access sets for non-empty intersections “When” determines the set operation Thread 1 Rd(a)Wr(b)Rd(c)- Mark Jeffrey and Greg Steffan, U of Toronto Thread 2 -Rd(a) -Rd(b) 9
Bloom Filters (BF) Mark Jeffrey and Greg Steffan, U of Toronto 10
Bloom Filter Background x = [x 31, … , x 3, x 2, x 1, x 0] h() [x 4, x 3, x 2, x 1] • Bloom filter is a compact set representation – Bit vector - much smaller than address space Mark Jeffrey and Greg Steffan, U of Toronto 11
Bloom Filter Background y Query for an address, y h() [y 4, y 3, y 2, y 1] {Yes, No} Mark Jeffrey and Greg Steffan, U of Toronto 12
Bloom Filter False Positives (FPs) • Encode a large address space into a bit-vector – Response to query is actually No or Maybe ? is y in • False Positives – when “maybe” is wrong x y Mark Jeffrey and Greg Steffan, U of Toronto 13
Partitioned Bloom Filter x h 1() h 2() … hk() … Insert an address, x: – k hash functions encode k bit indices to set Mark Jeffrey and Greg Steffan, U of Toronto 14
Partitioned Bloom Filter Query for an address, y: y h 1() h 2() … hk() … No} is well understood Probability of{Maybe, False Positives Mark Jeffrey and Greg Steffan, U of Toronto 15
Unconventional Practices for Bloom Filters Mark Jeffrey and Greg Steffan, U of Toronto 16
Bloom Filter for Set Overlaps Lazy systems perform set intersections Two common approaches: 1. build a Queue of Queries (Qo. Q) a 1 ? a 5 a 4 a 3 a 2 2. batch queries into distinct Bloom filter – replace many queries with 1 intersection! Mark Jeffrey and Greg Steffan, U of Toronto 17
Partitioned BF Intersection Do two sets share any elements? & … … … {Disjoint, Maybe Not} Mark Jeffrey and Greg Steffan, U of Toronto 18
Unpartitioned BF Intersection Any asserted bits indicate set overlap & … … … {Disjoint, Maybe Not} Mark Jeffrey and Greg Steffan, U of Toronto 19
False Set Overlap with BF Intersection • Bloom filter was intended for fast Querying • Recent systems use filter for Intersection – Imprecision can produce False Set Overlaps (FSO) – Limited study of Bloom filter intersection – Our goal is to Demystify Bloom filter Intersection Mark Jeffrey and Greg Steffan, U of Toronto 20
Important Questions When using BFs for address Set Overlaps: 1. how do BF Intersection and Qo. Q compare? – Empirical Study 2. what is the exact FSO probability? – Theoretical Study 3. what are theoretical implications? Mark Jeffrey and Greg Steffan, U of Toronto 21
Bloom Filters for Set Overlap 1. How do BF Intersection and Qo. Q compare? Mark Jeffrey and Greg Steffan, U of Toronto 22
Methodology For many trials: 1. Create sets A = {a 1, a 2, …, an} B = {b 1, b 2, …, bm} - A and B are disjoint B→ 2. A→ // Measure Intersects with FSOs 3. ∩ count # trials with a FSO // Measure Queues of Queries with FSOs 4. For each bi in B: is bi ϵ count # trials with at least one FP Mark Jeffrey and Greg Steffan, U of Toronto 23
Queue of Queries vs. Intersection FSO Rate for (A∩B=0? ), |A|=|B|= 32 False Set Overlap Rate 1 For equivalent FSO rate, Intersection requires ≥ 4 x more bits! 0. 8 0. 6 Qo. Q into Part. BF 4 x 0. 4 Part. Intersect Unpart. Intersect Better 0. 2 0 32 4 x 4 x 64 128 256 512 1 k 2 k 4 k 8 k 16 k 32 k 64 k 128 k Bloom filter Length (bits) Mark Jeffrey and Greg Steffan, U of Toronto 24
Queue of Queries vs. Intersection FSO Rate for (A∩B=0? ), |A|=|B|= 64 False Set Overlap Rate 1 Doubling address set from 32 to 64 => Doubling size from 4 x to 8 x 0. 8 0. 6 Qo. Q into Part. BF Part. Intersect 0. 4 Better 0. 2 0 32 8 x Unpart. Intersect 8 x 64 128 256 512 1 k 2 k 4 k 8 k 16 k 32 k 64 k 128 k Bloom filter Length (bits) Mark Jeffrey and Greg Steffan, U of Toronto 25
Empirical Study Summary i. BF Intersection requires > bits for == FSO rate ii. Space overhead increases with set size iii. Partitioned intersect is better than Unpartitioned Mark Jeffrey and Greg Steffan, U of Toronto 26
Bloom Filters for Set Overlap 2. What is the exact probability of False Set Overlap (FSO)? Mark Jeffrey and Greg Steffan, U of Toronto 27
Definitions Mark Jeffrey and Greg Steffan, U of Toronto 28
Definitions h 1() h 2() … … Mark Jeffrey and Greg Steffan, U of Toronto hk() 29
Probability of FSO • Unpartitioned BF Intersection • Partitioned BF Intersection h 1 h 2 … hk b 3 b 2 • Queue of BF Queries b 5 Mark Jeffrey and Greg Steffan, U of Toronto b 4 b 1 ϵ? 30
Theorem: BF(A)∩BF(B) vs. BF(A∩B) BF(A) BF(B) & BF(A)∩BF(B) A∩B h 1 h 2 … hk BF(A∩B) Theorem [Guo et al. TKDE ‘ 10]: Mark Jeffrey and Greg Steffan, U of Toronto 31
Bloom filters for Set Overlap 3. What are the Theoretical Implications? Mark Jeffrey and Greg Steffan, U of Toronto 32
False Conflicts: Qo. Q vs. Intersections Pr[FSO] for “A∩B=0? ”, k = 2 1 Pr[FSO] 0. 8 0. 6 Qo. Q into Partitioned 0. 4 Partitioned Intersect Better 0. 2 0 32 Unpartitioned Intersect 128 Bloom 512 filter Length 2 k 8 k (bits) 32 k 128 k For any length m, and k > 1 hash functions, • Queue of Queries gives fewer false conflicts • Partitioned intersection improves on Unpartitioned Mark Jeffrey and Greg Steffan, U of Toronto 33
Space: Qo. Q vs. Intersection Pr[FSO] for “A∩B=0? ”, k = 2 1 Pr[FSO] 0. 8 0. 6 Qo. Q into Partitioned 0. 4 Partitioned Intersect 0. 2 0 32 128 Bloom 512 2 k (bits) 8 k filter Length 32 k 128 k For equivalent Pr[FSO], when m. Partitioned≥|A||B|, k > 1, Mark Jeffrey and Greg Steffan, U of Toronto 34
Space: Qo. Q vs. Intersection Pr[FSO] for “A∩B=0? ”, k = 2 1 Pr[FSO] 0. 8 0. 6 Qo. Q into Partitioned 0. 4 Partitioned Intersect 0. 2 0 32 128 Bloom 512 2 k (bits) 8 k filter Length 32 k 128 k For equivalent Pr[FSO], when m. Partitioned≥|A||B|, k > 1, intersection requires at least square root factor more space. Mark Jeffrey and Greg Steffan, U of Toronto 35
Single Hash: Qo. Q vs. Intersection Pr[FSO] for “A∩B=0? ”, k = 1 1 Pr[FSO] 0. 8 0. 6 Qo. Q into Partitioned 0. 4 0. 2 0 Intersection Better 32 128 Bloom 512 2 k (bits) 8 k filter Length 32 k 128 k For a single hash function, k = 1, exploit the speed of intersection instead of queries! Mark Jeffrey and Greg Steffan, U of Toronto 36
Conclusion Mark Jeffrey and Greg Steffan, U of Toronto 37
Summary Conflict detection often applies Bloom filters – for fast set operations: y ϵ S and S 1∩S 2 – Many new systems use BF intersect Our recommendations (in order of preference) 1. strongly consider querying before intersection 2. intersect partitioned Bloom filters 3. if single hash is required, exploit intersection! Mark Jeffrey and Greg Steffan, U of Toronto 38
Current Work: Implementations • Analyze the effects of partitioning in Ring. STM • Analyze the effects of Qo. Q in Ring. STM • Develop a compromise in space and time – Reduce sqrt space overhead of BF Intersect – Reduce linear time complexity of Queue of Query Mark Jeffrey and Greg Steffan, U of Toronto 39
Understanding Bloom Filter Intersection for Lazy Address-Set Disambiguation Thank you! markj@eecg. toronto. edu
- Slides: 40