[go: up one dir, main page]

Skip to content

Latest commit

 

History

History

mem

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

AnchorHash - using less memory

This is a version that uses only half the memory for storing state, as compared to the version in the paper. It makes exactly the same hashing decisions and has exactly the same key lookup speed. The only difference is that each bucket remove takes slightly longer (order of a key lookup operation vs. O(1)). Bucket addition time is unchanged.

Code

This code is a direct replacement to AnchorHashQre.cpp and AnchorHashQre.hpp.

Try it

Go into the speed directory, run make, run the python script, and plot

Algorithm

INITWRAPPER(a,S)                // a anchor capacity, S list of resources, a>=|S|
  M←∅
  for i(0,1,...,|S|−1) do
    MM{(i,S[i])}              // mapping from bucket to resource
  INITANCHOR(a,|S|)

GETRESOURCE(k)                  // compute resource for key k
  bGETBUCKET(hash(k))          // convert key to int (e.g., rand(seed=k)) and call anchorHash
  ξM(b)
  return ξ

ADDRESOURCE(ξ)
  bADDBUCKET( )
  MM{(b,ξ)}

REMOVERESOURCE(ξ)
  bINV_M(ξ)
  MM\{(b,ξ)}
  REMOVEBUCKET(b)
INITANCHOR(a,w)                 // a anchor size (capacity), w number of workers (size)
  A[b]0 for b=0,1,...,a1      // W_b0 for bA
  R←∅                           // empty stack
  Nw                           // mumber of initially working buckets
  K[b]b for b=0,1,...,a1
  for b=a1 downtow do          // remove initially unused buckets
    R.push(b)
    A[b]b

BUCKETATVIEW(b,v)               // find who replaced b at view size v
  while A[b]>=v do              // b is removed for view size v
    bK(b)                      // search for W_v[b]
  return b

GETBUCKET(k)
  bhash(k) mod a               // can use k if calling through wrapper as it is already hash(key)
  while A[b]>0 do               // b is removed
    hh_b(k)                    // hhash(b,k) mod A[b] OR krand(seed=k), hk mod A[b]
    bBUCKETATVIEW(h,A[b])
  return b

ADDBUCKET( )
  bR.pop()
  NN+ 1
  A[b]0                        // WW  {b}, delete W_b
  K[b]b
  return b

REMOVEBUCKET(b)
  R.push(b)
  hBUCKETATVIEW(N-1,N)
  K[b]h
  NN1
  A[b]N                        // W_bW\b, A[b]←|W_b|