Robin Hood Hashing (Papers We Love SF August 2017)

Robin Hood Hashing (Papers We Love SF August 2017)

Robin Hood Hashing (1986) provided a breakthrough algorithm for storing data in hash tables, and has a really cool name. These slides were presented at the Papers We Love, Too meetup in San Francisco.

4c3ed917e59156a36212d48155831482?s=128

André Arko

August 24, 2017
Tweet

Transcript

  1. 4.

    Robin Hood Hashing (1986) example hash table data LEIA HAN

    REY LUKE : ALDERAAN : CORELLIA : JAKKU : TATTOOINE
  2. 11.

    Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE HASHING ALGORITHM 2 4 0 4
  3. 14.

    data stored in an array LEIA HAN REY LUKE 2

    4 0 4 Robin Hood Hashing (1986)
  4. 15.

    data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 Robin Hood Hashing (1986)
  5. 16.

    data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 Robin Hood Hashing (1986)
  6. 17.

    data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN Robin Hood Hashing (1986)
  7. 18.

    data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN Robin Hood Hashing (1986)
  8. 19.

    data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA Robin Hood Hashing (1986)
  9. 20.

    data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA Robin Hood Hashing (1986)
  10. 21.

    data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA REY:JAKKU Robin Hood Hashing (1986)
  11. 22.

    hash collisions LEIA HAN REY LUKE 2 4 0 4

    0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA REY:JAKKU Robin Hood Hashing (1986)
  12. 23.

    resolving collisions: chaining LEIA HAN REY LUKE 2 4 0

    4 0 1 2 3 4 LEIA:ALDERAAN HAN:CORELLIA REY:JAKKU Robin Hood Hashing (1986)
  13. 24.

    0 1 2 3 4 5 resolving collisions: open addressing

    LEIA HAN REY LUKE 2 4 0 4 LEIA:ALDERAAN HAN:CORELLIA REY:JAKKU Robin Hood Hashing (1986)
  14. 25.

    0 1 2 3 4 5 resolving collisions: open addressing

    LEIA HAN REY LUKE 2 4 0 4 LEIA:ALDERAAN HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE Robin Hood Hashing (1986)
  15. 26.

    0 1 2 3 4 5 resolving collisions: open addressing

    LEIA HAN REY LUKE FINN 2 4 0 4 5 LEIA:ALDERAAN HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE Robin Hood Hashing (1986)
  16. 27.

    0 1 2 3 4 5 6 Robin Hood Hashing

    (1986) resolving collisions: open addressing LEIA HAN REY LUKE FINN 2 4 0 4 5 LEIA:ALDERAAN HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT
  17. 28.

    0 1 2 3 4 5 6 7 8 9

    Robin Hood Hashing (1986) resolving collisions: open addressing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL 2 4 0 4 5 9 6 8 LEIA:ALDERAAN HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT+ CHEWIE:KASHYYK LANDO:BESPIN MAUL:DATHOMIR
  18. 29.

    0 1 2 3 4 5 6 7 8 9

    Robin Hood Hashing (1986) worst-case performance: it’s really bad LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT+ CHEWIE:KASHYYK LANDO:BESPIN MAUL:DATHOMIR LEIA:ALDERAAN
  19. 30.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) worst-case performance: it’s really bad LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT+ CHEWIE:KASHYYK+ LANDO:BESPIN+ MAUL:DATHOMIR+ WICKET:ENDOR LEIA:ALDERAAN
  20. 31.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data 6 slots away from ideal LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA + REY:JAKKU LUKE:TATTOOINE + FINN:CORUSCANT+ CHEWIE:KASHYYK+ LANDO:BESPIN+ MAUL:DATHOMIR+ WICKET:ENDOR LEIA:ALDERAAN
  21. 33.

    Robin Hood Hashing (1986) but a hero is on the

    horizon! Robin Hood Hashing offers vastly more efficient storage
  22. 34.

    Robin Hood Hashing (1986) how much better is it, really?

    O(ln n) probes, where n is items in the hash
  23. 35.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4
  24. 36.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 REY:JAKKU 0
  25. 37.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 REY:JAKKU 0 LEIA:ALDERAAN 0
  26. 38.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LEIA:ALDERAAN 0
  27. 39.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 LEIA:ALDERAAN 0
  28. 40.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 LEIA:ALDERAAN 0
  29. 41.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 CHEWIE:KASHYYK 0 LEIA:ALDERAAN 0
  30. 42.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 CHEWIE:KASHYYK 0 LANDO:BESPIN 1 LEIA:ALDERAAN 0
  31. 43.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 CHEWIE:KASHYYK 0 LANDO:BESPIN 1 MAUL:DATHOMIR 0 LEIA:ALDERAAN 0
  32. 44.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 FINN:CORUSCANT 1 CHEWIE:KASHYYK 0 LANDO:BESPIN 1 MAUL:DATHOMIR 0 LEIA:ALDERAAN 0
  33. 45.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 CHEWIE:KASHYYK 0 LANDO:BESPIN 1 MAUL:DATHOMIR 0 LEIA:ALDERAAN 0
  34. 46.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 CHEWIE:KASHYYK 0 FINN:CORUSCANT 2 MAUL:DATHOMIR 0 LEIA:ALDERAAN 0
  35. 47.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 CHEWIE:KASHYYK 0 FINN:CORUSCANT 2 LANDO:BESPIN 2 LEIA:ALDERAAN 0
  36. 48.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 MAUL:DATHOMIR 1 FINN:CORUSCANT 2 LANDO:BESPIN 2 LEIA:ALDERAAN 0
  37. 49.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) data stored in an array with robin hood hashing LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 MAUL:DATHOMIR 1 FINN:CORUSCANT 2 LANDO:BESPIN 2 LEIA:ALDERAAN 0 CHEWIE:KASHYYK 1
  38. 50.

    0 1 2 3 4 5 6 7 8 9

    10 Robin Hood Hashing (1986) only 2 slots away from ideal LEIA HAN REY LUKE FINN CHEWIE LANDO MAUL WICKET 2 4 0 4 5 9 6 8 4 HAN:CORELLIA 0 REY:JAKKU 0 LUKE:TATTOOINE 1 WICKET:ENDOR 2 MAUL:DATHOMIR 1 FINN:CORUSCANT 2 LANDO:BESPIN 2 LEIA:ALDERAAN 0 CHEWIE:KASHYYK 1
  39. 51.

    Robin Hood Hashing (1986) stealing from the rich and giving

    to the poor? that’s Robin Hood all over
  40. 52.

    Robin Hood Hashing (1986) further reading ‣ Robin Hood Hashing

    (1986 original paper) ‣ Robin Hood Hashing with Linear Probing paper (2005) ‣ Paul Khuong experimenting with hashing options (2009) ‣ Paul’s follow-up and conclusions (2011) ‣ Sebastian Sylvan saying robin hood should be the default (2013) ‣ Sebastian following up on slowness after deletions (2013) ‣ Emmanuel Goossaert benchmarking in C++ (2013) ‣ Paul Kuhong again, on linear probing for performance (2013) ‣ Emmanuel benchmarking again after tweaking deletions (2013)