Workshop: Introduction to the Disruptor

18,706 views
17,779 views

Published on

Trisha Gee of LMAX ran a workshop at Strange Loop 2012 giving a hands on set of exercises demonstrating the syntax of the Disruptor

Published in: Technology, Business

Workshop: Introduction to the Disruptor

  1. An Introduction to the LMAX Disruptor Trisha Gee, Developer at LMAX Exchange @trisha_gee mechanitis.blogspot.comTuesday, 25 September 12
  2. Laptop Setup... Go!Tuesday, 25 September 12
  3. The Disruptor?Tuesday, 25 September 12
  4. The Workshop • Introduction to the Disruptor • Simplest Case • Performance Results • Going Parallel • The Real World • QuestionsTuesday, 25 September 12
  5. What is The Disruptor? • Very fast message passing • Data structure and work flow without contention • Allows you to go truly parallelTuesday, 25 September 12
  6. So...?Tuesday, 25 September 12
  7. The Magic RingBufferTuesday, 25 September 12
  8. The Magic RingBufferTuesday, 25 September 12
  9. The Magic RingBufferTuesday, 25 September 12
  10. The Magic RingBufferTuesday, 25 September 12
  11. The Magic RingBufferTuesday, 25 September 12
  12. The Magic RingBufferTuesday, 25 September 12
  13. The Events are BucketsTuesday, 25 September 12
  14. I’ve got a RingBuffer! • Erm.... how do I poke things into it?Tuesday, 25 September 12
  15. The PublisherTuesday, 25 September 12
  16. Tuesday, 25 September 12
  17. Tuesday, 25 September 12
  18. Tuesday, 25 September 12
  19. Tuesday, 25 September 12
  20. Tuesday, 25 September 12
  21. Tuesday, 25 September 12
  22. ...so now I want to read • The Disruptor provides nice batching behaviour for freeTuesday, 25 September 12
  23. BatchEventProcessorTuesday, 25 September 12
  24. Tuesday, 25 September 12
  25. Tuesday, 25 September 12
  26. Tuesday, 25 September 12
  27. Tuesday, 25 September 12
  28. Tuesday, 25 September 12
  29. Tuesday, 25 September 12
  30. Tuesday, 25 September 12
  31. Tuesday, 25 September 12
  32. Tuesday, 25 September 12
  33. Tuesday, 25 September 12
  34. Tuesday, 25 September 12
  35. Tuesday, 25 September 12
  36. Tuesday, 25 September 12
  37. Tuesday, 25 September 12
  38. The ProblemTuesday, 25 September 12
  39. Tower Defence?Tuesday, 25 September 12
  40. Tuesday, 25 September 12
  41. Tuesday, 25 September 12
  42. Tuesday, 25 September 12
  43. Tuesday, 25 September 12
  44. Tuesday, 25 September 12
  45. Exercise One One publisher, one event handlerTuesday, 25 September 12
  46. Our ProblemTuesday, 25 September 12
  47. Simplest DisruptorTuesday, 25 September 12
  48. TODO • Print status of the enemy when the tower sees it • Print status of enemy after the tower shoots it • Shoot all enemiesTuesday, 25 September 12
  49. Task Breakdown • Wire up the EventTranslator & EventHandler, using the Disruptor class • Implement shootAt • Implement respawn & isDead • Get unit tests to pass • (check out mechanitis.examples.disruptor)Tuesday, 25 September 12
  50. Exercise One Goals 1. Understand the roles of Translators and Event Handlers 2. Understand how to wire up a simple Disruptor configuration 3. Understand how to get events flowing through the DisruptorTuesday, 25 September 12
  51. Performance vs a Queue Mac Air, 1.7GHz Core i5: run 0: BlockingQueue=3,390,060 Disruptor=69,108,500 ops/sec run 1: BlockingQueue=5,229,851 Disruptor=71,123,755 ops/sec run 2: BlockingQueue=4,303,481 Disruptor=65,530,799 ops/sec Disruptor - Time Taken: 3,242 millis Disruptor - Time Taken: 3,319 millis Disruptor - Time Taken: 4,045 millis Queue - Time Taken: 30,022 millis Queue - Time Taken: 31,823 millis Queue - Time Taken: 29,280 millisTuesday, 25 September 12
  52. Exercise Two One publisher, two parallel event handlersTuesday, 25 September 12
  53. Let’s log all the enemiesTuesday, 25 September 12
  54. Parallel ProcessorsTuesday, 25 September 12
  55. • Make each enemy unique • Write the details of each enemy generated into a text fileTuesday, 25 September 12
  56. Task Breakdown • Add randomness to enemy (e.g. give them a speed to travel at) • Wire in the EnemyLogger • Implement describeTo in enemyTuesday, 25 September 12
  57. Exercise Two Goals 1. Understand that EventHandlers can process in parallel 2. Understand how to wire up EventHandlers in parallel 3. Understand the caveats to going parallel - single writer principalTuesday, 25 September 12
  58. Exercise Three Diamond DependenciesTuesday, 25 September 12
  59. Recording the ResultsTuesday, 25 September 12
  60. Sequence BarriersTuesday, 25 September 12
  61. Managing DependenciesTuesday, 25 September 12
  62. • Don’t use the Disruptor Wizard for configuration • Record results of the game to a different text file • Optional: add variability to TurretTuesday, 25 September 12
  63. Task Breakdown • Remove use of Disruptor.java and wire up manually (mechanitis.examples.disruptor) • Wire in ResultHandler • Add missing things from Enemy classTuesday, 25 September 12
  64. Exercise Three Goals 1. Understand sequence barriers 2. Understand different dependency configurations 3. Understand wiring up without the wizardTuesday, 25 September 12
  65. Exercise Four Playtime!!Tuesday, 25 September 12
  66. Slow Consumers?Tuesday, 25 September 12
  67. The Real WorldTuesday, 25 September 12
  68. Tuesday, 25 September 12
  69. Tuesday, 25 September 12
  70. Tuesday, 25 September 12
  71. Ticket PurchasingTuesday, 25 September 12
  72. Tuesday, 25 September 12
  73. Tuesday, 25 September 12
  74. Tuesday, 25 September 12
  75. Tuesday, 25 September 12
  76. Tuesday, 25 September 12
  77. Tuesday, 25 September 12
  78. Tuesday, 25 September 12
  79. Other Uses • Queue replacement • Single-threading your code • Filtering • Coalescing • Dependency graphsTuesday, 25 September 12
  80. QuestionsTuesday, 25 September 12

×