SlideShare une entreprise Scribd logo
1  sur  80
Télécharger pour lire hors ligne
An Introduction to the
                  LMAX Disruptor
                           Trisha Gee, Developer at LMAX Exchange
                                          @trisha_gee
                                      mechanitis.blogspot.com




Tuesday, 25 September 12
Laptop Setup... Go!



Tuesday, 25 September 12
The Disruptor?



Tuesday, 25 September 12
The Workshop
                   • Introduction to the Disruptor
                   • Simplest Case
                   • Performance Results
                   • Going Parallel
                   • The Real World
                   • Questions
Tuesday, 25 September 12
What is The Disruptor?

                  • Very fast message passing
                  • Data structure and work flow without
                           contention
                  • Allows you to go truly parallel


Tuesday, 25 September 12
So...?



Tuesday, 25 September 12
The Magic RingBuffer




Tuesday, 25 September 12
The Magic RingBuffer




Tuesday, 25 September 12
The Magic RingBuffer




Tuesday, 25 September 12
The Magic RingBuffer




Tuesday, 25 September 12
The Magic RingBuffer




Tuesday, 25 September 12
The Magic RingBuffer




Tuesday, 25 September 12
The Events are Buckets




Tuesday, 25 September 12
I’ve got a RingBuffer!


                   • Erm.... how do I poke things into it?



Tuesday, 25 September 12
The Publisher




Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
...so now I want to read


                   • The Disruptor provides nice batching
                           behaviour for free




Tuesday, 25 September 12
BatchEventProcessor




Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
The Problem



Tuesday, 25 September 12
Tower Defence?




Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Exercise One
                           One publisher, one event handler




Tuesday, 25 September 12
Our Problem




Tuesday, 25 September 12
Simplest Disruptor




Tuesday, 25 September 12
TODO

                   • Print status of the enemy when the tower
                           sees it
                   • Print status of enemy after the tower
                           shoots it
                   • Shoot all enemies

Tuesday, 25 September 12
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
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 Disruptor



Tuesday, 25 September 12
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 millis




Tuesday, 25 September 12
Exercise Two
                           One publisher, two parallel event handlers




Tuesday, 25 September 12
Let’s log all the enemies




Tuesday, 25 September 12
Parallel Processors




Tuesday, 25 September 12
• Make each enemy unique
                   • Write the details of each enemy generated
                           into a text file




Tuesday, 25 September 12
Task Breakdown

                   • Add randomness to enemy (e.g. give them a
                           speed to travel at)
                   • Wire in the EnemyLogger
                   • Implement describeTo in enemy


Tuesday, 25 September 12
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 principal



Tuesday, 25 September 12
Exercise Three
                             Diamond Dependencies




Tuesday, 25 September 12
Recording the Results




Tuesday, 25 September 12
Sequence Barriers




Tuesday, 25 September 12
Managing Dependencies




Tuesday, 25 September 12
• Don’t use the Disruptor Wizard for
                           configuration

                   • Record results of the game to a different
                           text file

                   • Optional: add variability to Turret


Tuesday, 25 September 12
Task Breakdown

                   • Remove use of Disruptor.java and wire up
                           manually (mechanitis.examples.disruptor)
                   • Wire in ResultHandler
                   • Add missing things from Enemy class


Tuesday, 25 September 12
Exercise Three Goals

                   1. Understand sequence barriers
                   2. Understand different dependency
                      configurations
                   3. Understand wiring up without the wizard




Tuesday, 25 September 12
Exercise Four
                               Playtime!!




Tuesday, 25 September 12
Slow Consumers?




Tuesday, 25 September 12
The Real World



Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Ticket Purchasing




Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Tuesday, 25 September 12
Other Uses

                   • Queue replacement
                   • Single-threading your code
                   • Filtering
                   • Coalescing
                   • Dependency graphs

Tuesday, 25 September 12
Questions



Tuesday, 25 September 12

Contenu connexe

Similaire à Workshop: Introduction to the Disruptor

Building Cordova plugins for iOS
Building Cordova plugins for iOSBuilding Cordova plugins for iOS
Building Cordova plugins for iOS
Grgur Grisogono
 
Make something real for Firefox OS with Mozilla app templates
Make something real  for Firefox OS with Mozilla app templatesMake something real  for Firefox OS with Mozilla app templates
Make something real for Firefox OS with Mozilla app templates
Piotr Zalewa
 
Symfony - Introduction
Symfony - IntroductionSymfony - Introduction
Symfony - Introduction
Piers Warmers
 

Similaire à Workshop: Introduction to the Disruptor (12)

Reef - ESUG2011
Reef  - ESUG2011Reef  - ESUG2011
Reef - ESUG2011
 
Selenium Basics
Selenium BasicsSelenium Basics
Selenium Basics
 
Building Cordova plugins for iOS
Building Cordova plugins for iOSBuilding Cordova plugins for iOS
Building Cordova plugins for iOS
 
Make something real for Firefox OS with Mozilla app templates
Make something real  for Firefox OS with Mozilla app templatesMake something real  for Firefox OS with Mozilla app templates
Make something real for Firefox OS with Mozilla app templates
 
Architecting large Node.js applications
Architecting large Node.js applicationsArchitecting large Node.js applications
Architecting large Node.js applications
 
Capistrano
CapistranoCapistrano
Capistrano
 
Building Data Driven Products With Ruby - RubyConf 2012
Building Data Driven Products With Ruby - RubyConf 2012Building Data Driven Products With Ruby - RubyConf 2012
Building Data Driven Products With Ruby - RubyConf 2012
 
Node jsworkshop
Node jsworkshopNode jsworkshop
Node jsworkshop
 
Why can't organizations be designed as sexy as an iPad?
Why can't organizations be designed as sexy as an iPad?Why can't organizations be designed as sexy as an iPad?
Why can't organizations be designed as sexy as an iPad?
 
Scrum Master Role - Authority, Power and Leadership
Scrum Master Role - Authority, Power and LeadershipScrum Master Role - Authority, Power and Leadership
Scrum Master Role - Authority, Power and Leadership
 
The Wonderful World of Symfony Components
The Wonderful World of Symfony ComponentsThe Wonderful World of Symfony Components
The Wonderful World of Symfony Components
 
Symfony - Introduction
Symfony - IntroductionSymfony - Introduction
Symfony - Introduction
 

Plus de Trisha Gee

Plus de Trisha Gee (20)

Career Advice for Architects
Career Advice for Architects Career Advice for Architects
Career Advice for Architects
 
Is boilerplate code really so bad?
Is boilerplate code really so bad?Is boilerplate code really so bad?
Is boilerplate code really so bad?
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best Practices
 
Career Advice for Programmers - ProgNET London
Career Advice for Programmers - ProgNET LondonCareer Advice for Programmers - ProgNET London
Career Advice for Programmers - ProgNET London
 
Is Boilerplate Code Really So Bad?
Is Boilerplate Code Really So Bad?Is Boilerplate Code Really So Bad?
Is Boilerplate Code Really So Bad?
 
Real World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains WebinarReal World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains Webinar
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Career Advice for Programmers
Career Advice for Programmers Career Advice for Programmers
Career Advice for Programmers
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Becoming fully buzzword compliant
Becoming fully buzzword compliantBecoming fully buzzword compliant
Becoming fully buzzword compliant
 
Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and Tooling
 
Java 8 and 9 in Anger
Java 8 and 9 in AngerJava 8 and 9 in Anger
Java 8 and 9 in Anger
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
 
Migrating to IntelliJ IDEA from Eclipse
Migrating to IntelliJ IDEA from EclipseMigrating to IntelliJ IDEA from Eclipse
Migrating to IntelliJ IDEA from Eclipse
 
Code Review Matters and Manners
Code Review Matters and MannersCode Review Matters and Manners
Code Review Matters and Manners
 
Refactoring to Java 8 (QCon New York)
Refactoring to Java 8 (QCon New York)Refactoring to Java 8 (QCon New York)
Refactoring to Java 8 (QCon New York)
 
Refactoring to Java 8 (Devoxx UK)
Refactoring to Java 8 (Devoxx UK)Refactoring to Java 8 (Devoxx UK)
Refactoring to Java 8 (Devoxx UK)
 
Staying Ahead of the Curve
Staying Ahead of the CurveStaying Ahead of the Curve
Staying Ahead of the Curve
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Workshop: Introduction to the Disruptor