concurrent programming using the disruptor
play

Concurrent Programming Using The Disruptor Trisha Gee LMAX - PowerPoint PPT Presentation

Concurrent Programming Using The Disruptor Trisha Gee LMAX Wednesday, 23 May 12 Concurrent Programming Using The Disruptor Trisha Gee, Developer at LMAX @trisha_gee mechanitis.blogspot.com Wednesday, 23 May 12 The Disruptor? Wednesday,


  1. Concurrent Programming Using The Disruptor Trisha Gee LMAX Wednesday, 23 May 12

  2. Concurrent Programming Using The Disruptor Trisha Gee, Developer at LMAX @trisha_gee mechanitis.blogspot.com Wednesday, 23 May 12

  3. The Disruptor? Wednesday, 23 May 12

  4. What I’m covering • Overview of the Disruptor • Create your own! • Turn it up to Eleven • Q&A Wednesday, 23 May 12

  5. What is it? • Data structure and work flow with no contention. • Very fast message passing. • Allows you to go truly parallel. Wednesday, 23 May 12

  6. So...? Wednesday, 23 May 12

  7. The Magic RingBuffer Wednesday, 23 May 12

  8. The Magic RingBuffer Wednesday, 23 May 12

  9. The Magic RingBuffer Wednesday, 23 May 12

  10. The Magic RingBuffer Wednesday, 23 May 12

  11. The Magic RingBuffer Wednesday, 23 May 12

  12. The Magic RingBuffer Wednesday, 23 May 12

  13. The Magic RingBuffer Wednesday, 23 May 12

  14. Creating a RingBuffer final RingBuffer<SimpleEvent> ringBuffer = new RingBuffer<SimpleEvent>(SimpleEvent.EVENT_FACTORY, RING_BUFFER_SIZE); Wednesday, 23 May 12

  15. The Events are Buckets Wednesday, 23 May 12

  16. Great! I want one! public class SimpleEvent { public static final EventFactory<SimpleEvent> EVENT_FACTORY = new SimpleEventFactory(); private volatile String value; private static class SimpleEventFactory implements EventFactory<SimpleEvent> { @Override public SimpleEvent newInstance() { return new SimpleEvent(); } } } Wednesday, 23 May 12

  17. I’ve got a RingBuffer! • Erm.... how do I poke things into it? Wednesday, 23 May 12

  18. The Publisher Wednesday, 23 May 12

  19. Wednesday, 23 May 12

  20. Wednesday, 23 May 12

  21. Wednesday, 23 May 12

  22. Wednesday, 23 May 12

  23. Wednesday, 23 May 12

  24. Wednesday, 23 May 12

  25. What do I do? public class SimpleEventTranslator implements EventTranslator<SimpleEvent> SimpleEventTranslator translator = new SimpleEventTranslator(); EventPublisher<SimpleEvent> publisher = new EventPublisher<SimpleEvent>(ringBuffer); // poke your translator here // ...and when you’re done... publisher.publishEvent(translator); Wednesday, 23 May 12

  26. ...so now I want to read • The Disruptor provides nice batching behaviour for free Wednesday, 23 May 12

  27. Wednesday, 23 May 12

  28. Wednesday, 23 May 12

  29. Wednesday, 23 May 12

  30. Wednesday, 23 May 12

  31. Wednesday, 23 May 12

  32. Wednesday, 23 May 12

  33. Wednesday, 23 May 12

  34. Wednesday, 23 May 12

  35. Wednesday, 23 May 12

  36. Wednesday, 23 May 12

  37. Wednesday, 23 May 12

  38. Wednesday, 23 May 12

  39. Wednesday, 23 May 12

  40. Wednesday, 23 May 12

  41. Wednesday, 23 May 12

  42. ...and all you need is... public class SimpleEventHandler implements EventHandler<SimpleEvent> { @Override public void onEvent( final SimpleEvent event, final long sequence, final boolean endOfBatch) throws Exception { // do stuff } } Wednesday, 23 May 12

  43. Shiny. So what? Wednesday, 23 May 12

  44. Let’s go parallel Wednesday, 23 May 12

  45. And now for something different... Wednesday, 23 May 12

  46. Remember Henry Ford? Wednesday, 23 May 12

  47. Wednesday, 23 May 12

  48. Wednesday, 23 May 12

  49. Wednesday, 23 May 12

  50. Wednesday, 23 May 12

  51. Wednesday, 23 May 12

  52. Wednesday, 23 May 12

  53. Wednesday, 23 May 12

  54. Complex workflow... Wednesday, 23 May 12

  55. What on Earth has this got to do with RingBuffers?! Wednesday, 23 May 12

  56. Wednesday, 23 May 12

  57. Wednesday, 23 May 12

  58. Wednesday, 23 May 12

  59. Wednesday, 23 May 12

  60. Wednesday, 23 May 12

  61. Wednesday, 23 May 12

  62. Wednesday, 23 May 12

  63. Wednesday, 23 May 12

  64. Wednesday, 23 May 12

  65. Wednesday, 23 May 12

  66. Wednesday, 23 May 12

  67. Wednesday, 23 May 12

  68. Wednesday, 23 May 12

  69. Wednesday, 23 May 12

  70. Wednesday, 23 May 12

  71. Wednesday, 23 May 12

  72. Wednesday, 23 May 12

  73. Wednesday, 23 May 12

  74. Wednesday, 23 May 12

  75. Wednesday, 23 May 12

  76. Wednesday, 23 May 12

  77. Wednesday, 23 May 12

  78. Wednesday, 23 May 12

  79. Wednesday, 23 May 12

  80. Wednesday, 23 May 12

  81. Wednesday, 23 May 12

  82. Wednesday, 23 May 12

  83. Wednesday, 23 May 12

  84. Wednesday, 23 May 12

  85. Wednesday, 23 May 12

  86. Wednesday, 23 May 12

  87. Wednesday, 23 May 12

  88. Wednesday, 23 May 12

  89. Wednesday, 23 May 12

  90. Wednesday, 23 May 12

  91. Wednesday, 23 May 12

  92. Wednesday, 23 May 12

  93. Don’t wrap the buffer! ringBuffer.setGatingSequences(finalEventProcessor.getSequence()); Wednesday, 23 May 12

  94. Caveats Wednesday, 23 May 12

  95. Is that it? • Wait and claim strategies • Batch publishing • Multiple publishers • Different EventHandlers • The Wizard • You don’t even need a RingBuffer... Wednesday, 23 May 12

  96. You get... • A framework the encourages you to model your domain • The ability to run in parallel but single- threaded • Reliable ordering • ...and it can be very fast Wednesday, 23 May 12

  97. More Information • Google Code Site, including Wiki http://code.google.com/p/disruptor/ • Blogs, e.g. mine: mechanitis.blogspot.com • Presentations • Google Group Wednesday, 23 May 12

  98. Q&A Wednesday, 23 May 12

  99. WorkerPool Wednesday, 23 May 12

  100. AggregateEventHandler Wednesday, 23 May 12

Recommend


More recommend