Dont Thrash: How to Cache Your Hash in Flash M.A. Bender, M. - - PowerPoint PPT Presentation

don t thrash
SMART_READER_LITE
LIVE PREVIEW

Dont Thrash: How to Cache Your Hash in Flash M.A. Bender, M. - - PowerPoint PPT Presentation

Dont Thrash: How to Cache Your Hash in Flash M.A. Bender, M. Farach-Colton, R. Johnson, B.C. Kuszmaul, D. Medjedovic, P. Montes , P. Shetty, R. P. Spillane , E. Zadok Stony Brook U., Rutgers U., MIT, TokuTek Bloom Filter Cache (e.g., RAM)


slide-1
SLIDE 1

Don’t Thrash: How to Cache Your Hash in Flash

M.A. Bender, M. Farach-Colton, R. Johnson, B.C. Kuszmaul, D. Medjedovic, P. Montes,

  • P. Shetty, R. P. Spillane, E. Zadok

Stony Brook U., Rutgers U., MIT, TokuTek

slide-2
SLIDE 2

Bloom Filter

  • A Bloom filter is a bit-array + k hash functions
  • Storing a few bits per element lets the BF stay in

RAM, even as the elements are too large

Don't Thrash: How to Cache Your Hash in Flash

2

A B 1 1 1

Elements stored in the Bloom filter Bit-array Each element is hashed To K positions in the bit-array. Here k=2

Cache (e.g., RAM) Store

slide-3
SLIDE 3

Bloom Filter Lookups & False Positives

  • False positives unlikely,
  • No false negatives (no means no)
  • Allowing false positives is what keeps the BF small

Don't Thrash: How to Cache Your Hash in Flash

3

A B 1 1 1

B

pFP x

( ) » 1-ekn/m

( )

k

D A C

lookup

B h

1(D)

[ ] = 0

B h2(D)

[ ] =1

False positive

(C was never inserted)

slide-4
SLIDE 4

Flash

  • Bigger & cheaper than RAM, faster than disk
  • 8TB of 512B keys needs 16GB of RAM for a ~1% BF
  • Flash is a good place to cheaply store large BFs

Don't Thrash: How to Cache Your Hash in Flash

4

RAM A B 1 1 1 Flash Store

B

slide-5
SLIDE 5

Thrashing

  • Setting random bits to 1 causes random writes
  • OK in RAM, not in Flash

Don't Thrash: How to Cache Your Hash in Flash

5

1 1 1 Flash

B

C

Random writes

slide-6
SLIDE 6

Summary of Our Results

  • Cascade Filter (CF), a BF replacement opt. for fast

inserts on Flash

  • Our performance

– We do 670,000 inserts/sec (40x of other variants) – We do 530 lookups/sec (1/3x of other variants)

  • We use Quotient Filters (QF) instead of Bloom Filters

– They have better access locality – You can efficiently merge two QFs into a larger QF (w/ same FP rate)

  • We use merging techniques to compose multiple QFs

into a CF

Don't Thrash: How to Cache Your Hash in Flash

6

slide-7
SLIDE 7

Thrashing is the Problem

  • Every insert, you write to K Flash pages
  • Expensive to write to a Flash page
  • We can’t do fast insertions without working

around this issue

Don't Thrash: How to Cache Your Hash in Flash

7

Random Writes

K C Flash

slide-8
SLIDE 8

Shaving off K

  • Now you only write one block for each insert

instead of K blocks

  • Two-step hash [Canim et. al., 2010]
  • This helps a little

Don't Thrash: How to Cache Your Hash in Flash

8

Now just one random write, not K

K C Flash

slide-9
SLIDE 9

Queue Writes

  • This helps a lot [Canim et. al. 2010]
  • Buffering gives bit-flips a chance to piggy-back
  • How others have cached hashes in Flashes

Don't Thrash: How to Cache Your Hash in Flash

9

RAM 1 3 3 1 1 1 1 Flash

B

4 B A D 1

We write 5 bits with

  • nly 2 flash writes
slide-10
SLIDE 10

We Need Help

  • Buffering works when the queue is large
  • Small queues insert ~1 element per flash write
  • We’re interested in large datasets, and fast

insertions (i.e., when buffering doesn’t work)

Don't Thrash: How to Cache Your Hash in Flash

10

RAM Flash

slide-11
SLIDE 11

An Important Problem

  • Many companies optimize their DBs for large

data-sets and fast inserts

– Bai-Du Hypertable – Facebook Cassandra – Google BigTable – TokuTek TokuDB – Yahoo! HBase – … and more!

  • Scaling the trusty Bloom Filter to Flash would be

a powerful tool for tackling these problems

Don't Thrash: How to Cache Your Hash in Flash

11

slide-12
SLIDE 12

Several data structures avoid RWs

  • A list of the most common methods

– Buffered Repository Trees – Cassandra – Cache Oblivious Look-ahead Arrays – Log-structured Merge Trees – …and more

  • We can try to adapt the general method many
  • f these structures use

Don't Thrash: How to Cache Your Hash in Flash

12

slide-13
SLIDE 13

The General Method

  • Supports deletes
  • Composed of many sorted lists
  • We can use this technique to avoid random writes

Don't Thrash: How to Cache Your Hash in Flash

13

RAM 2 Store 7 4 7 1 3 9 5 6 8 2 4 8 1 3 5 6 8 9

Lookup 8 No No Found 2 Previously flushed buffers Buffers are merged to keep total number of buffers low £ logN é ê ù ú

slide-14
SLIDE 14

Problem: Elements not Bits

  • This method is used with sorted lists of

elements, not Bloom filters

  • We need a data structure that

– Supports insert + lookup – Is as space efficient as a Bloom filter – Can be merged on Flash like a sorted list of elements – Bonus: supports always-working deletes – Bonus: faster than BFs

Don't Thrash: How to Cache Your Hash in Flash

14

slide-15
SLIDE 15

Our Proposal: Quotient Filters

  • Supports insert + lookup
  • Compact like a Bloom filter
  • Two QFs can be merged into a larger QF
  • Supports always-working deletes
  • Faster
  • We can use this alternative to replace the

sorted lists of elements in a write-opt. method

Don't Thrash: How to Cache Your Hash in Flash

15

slide-16
SLIDE 16

A Quotient Filter

  • fingerprints + quotienting to save space
  • fingerprint: p-bit hash (p=5)
  • Compact, only stores r+MD bits per element

Don't Thrash: How to Cache Your Hash in Flash

16

A B 101 000 110 000

r-bit array r=3 h(A)=00:101 h(B)=10:110 00 01 10 11 address:identity Q[10]=110 2 or 3 MD bits per element

slide-17
SLIDE 17

A Quotient Filter

  • False positive: fingerprint collision
  • , , or ~1.2x a BF for ~0.1% FP-rate
  • Quotient Filters also remain small by allowing false positives

Don't Thrash: How to Cache Your Hash in Flash

17

A B 101 000 110 111

r-bit array r=3 h(B)=10:110 00 01 10 11

A C E D

h(D)=10:111 h(C)=01:010 h(E)=10:110 False positive

(E was never inserted)

Soft collision

(push D to the side, use a few MD bits to remember)

pFP x

( ) £a 1

2r

size =a-1 r + MD

( )2q

h(A)=00:101

slide-18
SLIDE 18

But Will it Merge?

  • Actually, a compact sorted list of integers

Don't Thrash: How to Cache Your Hash in Flash

18

A B 101 000 110 111

r-bit array r=3 00 01 10 11

D

00:101=5 10:110=22 10:111=23

slide-19
SLIDE 19

Merge as Integers, Then Insert

  • QFs support Plug-n-Play with wrt.-opt. DSes

Don't Thrash: How to Cache Your Hash in Flash

19

00 00:101=5 10:110=22 001:01=5

00 01 00 00 00 10

r-bit array r=2 101:10=22 000 001 010 011 100

11 00

101 110 111 10:111=23 101:11=23

A B C 101

01

000

10

111

11

000

00

000

01

000

10

110

11

000

r-bit arrays r=3

slide-20
SLIDE 20

Cascade Filter

  • Just substitute sorted lists of elements with Quotient

Filters instead

  • Now we have fast insertions and a compact

representation in Flash

Don't Thrash: How to Cache Your Hash in Flash

20

RAM QF Store QF QF QF

£ logN é ê ù ú

slide-21
SLIDE 21

Experimental Setup

  • Everything was the same (e.g., cache size)
  • Inserted 8.4 billion hashes
  • Randomly queried them

Don't Thrash: How to Cache Your Hash in Flash

21

slide-22
SLIDE 22

Insertion Throughput

Don't Thrash: How to Cache Your Hash in Flash

22

1E+09 2E+09 3E+09 4E+09 5E+09 6E+09 7E+09 8E+09 9E+09 2000 4000 6000 8000 10000 12000 14000

Large Merges Thruput much higher: 40x higher than BBF 3000x higher than BF Seconds Number of Fingerprints Inserted Peak append thruput: 8.4MB/S

slide-23
SLIDE 23

Lookup Throughput

Don't Thrash: How to Cache Your Hash in Flash

23

1 10 100 1000 10000

CF Traditional BF Elevator BF 530 lkus/sec 1600 lkus/sec 1600 lkus/sec Lookup Throughput 1/3x

slide-24
SLIDE 24

Conclusions

  • Quotient Filters outperform BFs in RAM

– 3x faster inserts, same lookups – Support deletes – Can be dynamically resized

  • Cascade Filters outperform BFs in Flash

– All advantages of Quotient Filters (e.g., deletes) – 40x faster inserts, 1/3x lookups – CPU bound

Don't Thrash: How to Cache Your Hash in Flash

24

slide-25
SLIDE 25

Future Work

  • Tweak the CF to handle buffering as well
  • Measure real index workloads
  • Can a CF help a write-optimized DB?
  • There are a lot of exciting boulevards to

explore

Don't Thrash: How to Cache Your Hash in Flash

25

slide-26
SLIDE 26

And That is How…

  • …you Don’t Thrash, when you Cache Your

Hash in Flash

  • Thank you for listening, Questions?

– Pablo Montes: pmontes@cs.stonybrook.edu – Rick Spillane: rick@fsl.cs.sunysb.edu

Don't Thrash: How to Cache Your Hash in Flash

26

slide-27
SLIDE 27

Insertion Throughput

Don't Thrash: How to Cache Your Hash in Flash

27

1 10 100 1000 10000 100000 1000000

CF Traditional BF Elevator BF 670,000 ins/sec 200 ins/sec 17000 ins/sec Insertion Throughput 40x 3000x

slide-28
SLIDE 28

Experimental Setup

  • Controls:

– ~Equal DS cache size, BF given benefit of doubt – Equal RAM in all runs/tests – BF tests run in steady-state for 4+ hours – CF tests run for 8.4 billion insertions (~16GB CF) – Flash partition 60% of Intel X25-Mv2, 90GB

  • Machine:

– Quad-core 2.4GHz Xeon E5530 with 8MB cache – 24GB of RAM (booted with 0.994GB) – 159.4GB Intel X-25M SSD (second generation)

Don't Thrash: How to Cache Your Hash in Flash

28

slide-29
SLIDE 29

Future Work

  • Measure CF effectiveness for read-optimized
  • Measure real index workloads
  • Can a CF help a write-optimized DB?
  • Better CPU/GPU optimization
  • There are a lot of exciting boulevards to

explore

Don't Thrash: How to Cache Your Hash in Flash

29