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. Robin Hood Hashing (Pedro Celis, 1986) Papers We Love

  2. André Arko this is me, @indirect

  3. Robin Hood Hashing

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

    REY LUKE : ALDERAAN : CORELLIA : JAKKU : TATTOOINE
  5. Robin Hood Hashing (1986) example hash table data LEIA HAN

    REY LUKE
  6. Robin Hood Hashing (1986) example hash table data LEIA HAN

    REY LUKE
  7. Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE
  8. Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE
  9. Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE HASHING ALGORITHM
  10. Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE HASHING ALGORITHM
  11. Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE HASHING ALGORITHM 2 4 0 4
  12. Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE 2 4 0 4
  13. Robin Hood Hashing (1986) keys hashed to index values LEIA

    HAN REY LUKE 2 4 0 4
  14. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 Robin Hood Hashing (1986)
  15. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 Robin Hood Hashing (1986)
  16. data stored in an array LEIA HAN REY LUKE 2

    4 0 4 0 1 2 3 4 Robin Hood Hashing (1986)
  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)
  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)
  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)
  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)
  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)
  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)
  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)
  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)
  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)
  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)
  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
  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
  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
  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
  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
  32. Robin Hood Hashing (1986) as you can probably imagine, this

    gets very bad, very quickly
  33. Robin Hood Hashing (1986) but a hero is on the

    horizon! Robin Hood Hashing offers vastly more efficient storage
  34. Robin Hood Hashing (1986) how much better is it, really?

    O(ln n) probes, where n is items in the hash
  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
  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
  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
  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
  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
  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
  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
  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
  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
  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
  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
  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
  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
  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
  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
  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
  51. Robin Hood Hashing (1986) stealing from the rich and giving

    to the poor? that’s Robin Hood all over
  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)
  53. Robin Hood Hashing (1986) thanks! slides
 bit.ly/indirect-robin-hood-hashing twitter
 @indirect email


    andre@arko.net