SlideShare a Scribd company logo
learned 
Stuff I’ve learnt about 
software performance 
@mikeb2701
• What is a financial exchange? 
• How to lie with numbers 
• Design is (almost) everything 
• Everything else is about making trade-offs
TL;DR 
1. Low Latency 
2. ??? 
3. Profit
Lies, Damed Lies and 
Performance Numbers
320μs @ 10,000 tx/s
Customer 
Fix 
Gateway 
Load 
Balancer 
Execution 
Venue 
Record Latency 
Parse/Encode FIX 
Order Matching 
Replication 
Journalling
320μs @ 10,000 tx/s
320μs @ 10,000 tx/s
http://www.infoq.com/presentations/latency-pitfalls
What did I learn 
• Detail Matters 
• Don’t oversimplify the behaviour of your system
If we can really understand the problem, the 
answer will come out of it, because the answer is 
not separate from the problem. 
! 
- Jiddu Krishnamurti
Customer 
Fix 
Gateway 
Load 
Balancer 
Execution 
Venue 
Record Latency 
Parse/Encode FIX 
Order Matching 
Replication 
Journalling
Instruction 
Execution 
Report 
Execution Venue 
OrderBook 
Order 
Execution
Execution Venue 
CreateOrderBook 
<Admin Instruction> 
instrument: Carrots
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
CreateOrderBook 
<Admin Instruction> 
instrument: Carrots
PlaceOrder 
<Instruction> 
id : ABC 
instrument: Carrots 
price : 110 
quantity : 5 
side : BID 
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots
PlaceOrder 
<Instruction> 
id : ABC 
instrument: Carrots 
price : 110 
quantity : 5 
side : BID 
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
Order 
<Entity> 
orderId : 1 
id : ABC 
price : 110 
quantity : 5 
side : BID 
filled : 0 
cancelled : 0
PlaceOrder 
<Instruction> 
id : ABC 
instrument: Carrots 
price : 110 
quantity : 5 
side : BID 
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
Order 
<Entity> 
orderId : 1 
id : ABC 
price : 110 
quantity : 5 
side : BID 
filled : 0 
cancelled : 0 
Accept 
<ExecutionReport> 
id : ABC 
LiquidityAdded 
<ExecutionReport> 
instrument: Carrots 
price : 110 
quantity : 5
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
Order 
<Entity> 
orderId : 1 
id : ABC 
price : 110 
quantity : 5 
side : BID 
filled : 0 
cancelled : 0 
CancelOrder 
<Instruction> 
originalId: ABC
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
CancelOrder 
<Instruction> 
originalId: ABC 
Cancelled 
<ExecutionReport> 
id : ABC 
instrument: Carrots 
price : 110 
quantity : 5 
Order 
<Entity> 
orderId : 1 
id : ABC 
price : 110 
quantity : 5 
side : BID 
filled : 0 
cancelled : 5
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
CancelOrder 
<Instruction> 
originalId: ABC 
Cancelled 
<ExecutionReport> 
id : ABC 
instrument: Carrots 
price : 110 
quantity : 5
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
Order 
<Entity> 
orderId : 1 
id : ABC 
price : 110 
quantity : 5 
side : BID 
filled : 0 
cancelled : 0 
PlaceOrder 
<Instruction> 
id : DEF 
instrument: Carrots 
price : 110 
quantity : 5 
side : ASK
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
PlaceOrder 
<Instruction> 
id : DEF 
instrument: Carrots 
price : 110 
quantity : 5 
side : ASK 
Accept 
<ExecutionReport> 
id : DEF 
Trade 
<ExecutionReport> 
price : 110 
quantity : 5 
aggressive: DEF 
passive : ABC 
Order 
<Entity> 
orderId : 1 
id : ABC 
price : 110 
quantity : 5 
side : BID 
filled : 5 
cancelled : 0
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
PlaceOrder 
<Instruction> 
id : DEF 
instrument: Carrots 
price : 110 
quantity : 5 
side : ASK 
Accept 
<ExecutionReport> 
id : DEF 
Trade 
<ExecutionReport> 
price : 110 
quantity : 5 
aggressive: DEF 
passive : ABC
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
PlaceOrder 
<Instruction> 
id : ABC 
instrument: Bananas 
price : 110 
quantity : 5 
side : BID
Execution Venue 
OrderBook 
<Entity> 
instrument: Carrots 
PlaceOrder 
<Instruction> 
id : ABC 
instrument: Bananas 
price : 110 
quantity : 5 
side : BID 
Reject 
<ExecutionReport> 
id : ABC
Interesting Properties 
• Stable working set 
• Fits in memory 
• Doesn’t not grow monotonically with time 
• All decisions are made from local information
Event-Sourced Service 
Journalling 
Replication 
Business 
Logic 
Message Message 
http://www.infoq.com/presentations/Event-Sourced-Architectures-for-High-Availability
What did I learn 
• Enough understanding of the problem and 
solutions will appear 
• Pay attention to: 
• Entity Life-cycles 
• Number of entities - in real world scenarios 
• Try to approach the problem without bias
If you can’t talk about the downside and the 
trade offs then you’re just a fan person waiving 
a coffee mug around. That type of behaviour 
really doesn’t benefit anyone. 
! 
- Some guy on the Internet (charmalloc) 
Source: http://allthingshadoop.com/2013/12/06/technology-decisions-are-about-trade-offs-and-solving-problems/
Customer 
Fix 
Gateway 
Load 
Balancer 
10K 
msg/sec 
Execution 
Venue 
Market Data 
Service 
160K 
msg/sec
Design for trade-offs
TIMESTAMP,BID_PRICE_1,BID_QTY_1,ASK_PRICE_1,ASK_QTY_1 
1405890300827,1.35263,50,1.35296,50 
1405890300908,1.35263,50,1.35296,49.9 
1405890300909,1.35263,50,1.35296,47.9 
1405890301090,1.35263,48.2,1.35296,47.9 
1405890301193,1.35263,48.2,1.35296,46.1 
1405890301194,1.35263,48.2,1.35296,44.6 
1405890301280,1.35263,48.2,1.35296,42.6 
1405890301571,1.35263,48.1,1.35296,42.6 
1405890303037,1.35263,47.1,1.35296,42.6
List<String[]> lines = ! 
parseAsList("data.csv");! 
for (String[] line : lines)! 
{! 
double bid = parseDouble(line[1]);! 
double ask = parseDouble(line[3]);! 
! 
// Stuff...! 
}!
Iterable<String[]> lines = ! 
parseAsIterable("data.csv");! 
for (String[] line : lines)! 
{! 
double bid = parseDouble(line[1]);! 
double ask = parseDouble(line[3]);! 
! 
// Stuff...! 
}!
public interface CsvObservable! 
{! 
default void onError(Exception e)! 
{! 
}! 
! 
default void onComplete()! 
{! 
}! 
! 
void onEvent(! 
int row, int column, ! 
CharSequence value, boolean endOfLine);! 
}
parse("data.csv", ! 
(row, column, value, endOfLine) ->! 
{! 
switch (column)! 
{! 
case 1:! 
bid = parseDouble(value);! 
case 3:! 
ask = parseDouble(value);! 
}! 
! 
// Stuff...! 
});
Ops/sec GC Count GC Time (ms) 
Iterable 8.20 104 154 
Observable 16.75 0 0
public class CsvObservableDelegate ! 
implements CsvObservable<CharSequence>! 
{! 
private CsvObservable<String> delegate;! 
! 
public CsvObservableDelegate(CsvObservable<String> delegate)! 
{! 
this.delegate = delegate;! 
}! 
! 
public void onEvent(! 
int row, int column, ! 
CharSequence value, boolean endOfLine)! 
{! 
delegate.onEvent(! 
row, column, value.toString(), endOfLine);! 
}! 
! 
// Other delegate methods! 
}!
Garbage Collection 
Stallin’ your app since 1959
mean 95% 99% 99.99% 
JDK6 1.386 1.82 5.75 15.72 
JDK7 1.44 1.79 11.75 20.66
Solutions 
•Don’t Generate Any 
• Use Zing (Azul Systems)
Why Use Java? 
(why not C/C++/..)
Source: https://software.intel.com/en-us/articles/introduction-to-intel-advanced-vector-extensions
public class Doubles ! 
{ ! 
public static void sum(! 
double[] sum, ! 
double[] addendA, ! 
double[] addendB)! 
{! 
for (int i = 0; i < 0 + sum.length; i++)! 
{! 
sum[i] = addendA[i] + addendB[i];! 
}! 
}! 
}!
#include <immintrin.h>! 
! 
void sum(double* c, double* a, double* b, int len)! 
{! 
__m256d rA_AVX, rB_AVX, rC_AVX;! 
! 
for (int i = 0; i < len; i += 4)! 
{! 
rA_AVX = _mm256_load_pd(&a[i]);! 
rB_AVX = _mm256_load_pd(&b[i]);! 
rC_AVX = _mm256_add_pd(rA_AVX, rB_AVX);! 
_mm256_store_pd(&c[i], rC_AVX);! 
}! 
}!
More Java vs. C++ 
https://github.com/real-logic/simple-binary-encoding
What did I learn? 
• Details matter (performance measurement) 
• Let the problem define the solution 
• Design without bias 
• Understand the costs/benefits of trade-offs 
• Design to let others make trade-offs 
• Some trade-offs are not technical
Q&A
Links 
• Measuring Latency - http://goo.gl/6bllUP 
• Event Sourcing - http://goo.gl/VcZI7l 
• LMAX Architecture - http://goo.gl/UI5z0T 
• Source Code 
• http://github.com/mikeb01/qconsf2014

More Related Content

Similar to Stuff I Learned About Performance

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Brains & Brawn: the Logic and Implementation of a Redesigned Advertising Mark...
Brains & Brawn: the Logic and Implementation of a Redesigned Advertising Mark...Brains & Brawn: the Logic and Implementation of a Redesigned Advertising Mark...
Brains & Brawn: the Logic and Implementation of a Redesigned Advertising Mark...
PyData
 
There and Back Again
There and Back AgainThere and Back Again
There and Back Again
Joshua Ballanco
 
Practical Machine Learning
Practical Machine LearningPractical Machine Learning
Practical Machine Learning
David Jones
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDD
Konstantin Kudryashov
 
High Performance Managed Languages
High Performance Managed LanguagesHigh Performance Managed Languages
High Performance Managed Languages
J On The Beach
 
Why Agile Works But Isn't Working For You
Why Agile Works But Isn't Working For YouWhy Agile Works But Isn't Working For You
Why Agile Works But Isn't Working For You
David Harvey
 
Natural born conversion killers - Conversion Jam
Natural born conversion killers - Conversion JamNatural born conversion killers - Conversion Jam
Natural born conversion killers - Conversion Jam
Craig Sullivan
 
Serverless in production, an experience report (London DevOps)
Serverless in production, an experience report (London DevOps)Serverless in production, an experience report (London DevOps)
Serverless in production, an experience report (London DevOps)
Yan Cui
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing10Pines
 
I don’t understand it fido
I don’t understand it fidoI don’t understand it fido
I don’t understand it fido
Erle Howard
 
Voicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.comVoicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.comVoxeo Corp
 
Building the "right" regression suite using Behavior Driven Testing (BDT)
Building the "right" regression suite using Behavior Driven Testing (BDT)Building the "right" regression suite using Behavior Driven Testing (BDT)
Building the "right" regression suite using Behavior Driven Testing (BDT)
Anand Bagmar
 
Contoh Desain Slide Presentasi Ilmiah Kreatif dan Menarik #1
Contoh Desain Slide Presentasi Ilmiah Kreatif dan Menarik #1Contoh Desain Slide Presentasi Ilmiah Kreatif dan Menarik #1
Contoh Desain Slide Presentasi Ilmiah Kreatif dan Menarik #1
Arry Rahmawan
 
Acceptance Test Driven Development at StarWest 2014
Acceptance Test Driven Development at StarWest 2014Acceptance Test Driven Development at StarWest 2014
Acceptance Test Driven Development at StarWest 2014
jaredrrichardson
 
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Ruby Meditation
 
Effective Testing with Ruby
Effective Testing with RubyEffective Testing with Ruby
Effective Testing with RubyAkira Sosa
 
Need for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API ProjectsNeed for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API Projects
Łukasz Chruściel
 
Tech campmemphis slides_post_session
Tech campmemphis slides_post_sessionTech campmemphis slides_post_session
Tech campmemphis slides_post_session
Stewart Whaley
 

Similar to Stuff I Learned About Performance (20)

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Brains & Brawn: the Logic and Implementation of a Redesigned Advertising Mark...
Brains & Brawn: the Logic and Implementation of a Redesigned Advertising Mark...Brains & Brawn: the Logic and Implementation of a Redesigned Advertising Mark...
Brains & Brawn: the Logic and Implementation of a Redesigned Advertising Mark...
 
There and Back Again
There and Back AgainThere and Back Again
There and Back Again
 
Practical Machine Learning
Practical Machine LearningPractical Machine Learning
Practical Machine Learning
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDD
 
High Performance Managed Languages
High Performance Managed LanguagesHigh Performance Managed Languages
High Performance Managed Languages
 
Why Agile Works But Isn't Working For You
Why Agile Works But Isn't Working For YouWhy Agile Works But Isn't Working For You
Why Agile Works But Isn't Working For You
 
Natural born conversion killers - Conversion Jam
Natural born conversion killers - Conversion JamNatural born conversion killers - Conversion Jam
Natural born conversion killers - Conversion Jam
 
Serverless in production, an experience report (London DevOps)
Serverless in production, an experience report (London DevOps)Serverless in production, an experience report (London DevOps)
Serverless in production, an experience report (London DevOps)
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing
 
I don’t understand it fido
I don’t understand it fidoI don’t understand it fido
I don’t understand it fido
 
Voicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.comVoicecon - Mashups with Tropo.com
Voicecon - Mashups with Tropo.com
 
Scalingprezo
ScalingprezoScalingprezo
Scalingprezo
 
Building the "right" regression suite using Behavior Driven Testing (BDT)
Building the "right" regression suite using Behavior Driven Testing (BDT)Building the "right" regression suite using Behavior Driven Testing (BDT)
Building the "right" regression suite using Behavior Driven Testing (BDT)
 
Contoh Desain Slide Presentasi Ilmiah Kreatif dan Menarik #1
Contoh Desain Slide Presentasi Ilmiah Kreatif dan Menarik #1Contoh Desain Slide Presentasi Ilmiah Kreatif dan Menarik #1
Contoh Desain Slide Presentasi Ilmiah Kreatif dan Menarik #1
 
Acceptance Test Driven Development at StarWest 2014
Acceptance Test Driven Development at StarWest 2014Acceptance Test Driven Development at StarWest 2014
Acceptance Test Driven Development at StarWest 2014
 
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
 
Effective Testing with Ruby
Effective Testing with RubyEffective Testing with Ruby
Effective Testing with Ruby
 
Need for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API ProjectsNeed for Speed: Removing speed bumps in API Projects
Need for Speed: Removing speed bumps in API Projects
 
Tech campmemphis slides_post_session
Tech campmemphis slides_post_sessionTech campmemphis slides_post_session
Tech campmemphis slides_post_session
 

More from Michael Barker

Value Types
Value TypesValue Types
Value Types
Michael Barker
 
Test automation 3
Test automation 3Test automation 3
Test automation 3
Michael Barker
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Michael Barker
 
Beginners guide-concurrency
Beginners guide-concurrencyBeginners guide-concurrency
Beginners guide-concurrencyMichael Barker
 
Disruptor tools in action
Disruptor   tools in actionDisruptor   tools in action
Disruptor tools in actionMichael Barker
 

More from Michael Barker (6)

Value Types
Value TypesValue Types
Value Types
 
Test automation 3
Test automation 3Test automation 3
Test automation 3
 
Concurrecy techdrop
Concurrecy techdropConcurrecy techdrop
Concurrecy techdrop
 
Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!Lock? We don't need no stinkin' locks!
Lock? We don't need no stinkin' locks!
 
Beginners guide-concurrency
Beginners guide-concurrencyBeginners guide-concurrency
Beginners guide-concurrency
 
Disruptor tools in action
Disruptor   tools in actionDisruptor   tools in action
Disruptor tools in action
 

Recently uploaded

Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 

Recently uploaded (20)

Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 

Stuff I Learned About Performance

  • 1. learned Stuff I’ve learnt about software performance @mikeb2701
  • 2. • What is a financial exchange? • How to lie with numbers • Design is (almost) everything • Everything else is about making trade-offs
  • 3.
  • 4. TL;DR 1. Low Latency 2. ??? 3. Profit
  • 5. Lies, Damed Lies and Performance Numbers
  • 7. Customer Fix Gateway Load Balancer Execution Venue Record Latency Parse/Encode FIX Order Matching Replication Journalling
  • 9.
  • 12. What did I learn • Detail Matters • Don’t oversimplify the behaviour of your system
  • 13. If we can really understand the problem, the answer will come out of it, because the answer is not separate from the problem. ! - Jiddu Krishnamurti
  • 14. Customer Fix Gateway Load Balancer Execution Venue Record Latency Parse/Encode FIX Order Matching Replication Journalling
  • 15. Instruction Execution Report Execution Venue OrderBook Order Execution
  • 16. Execution Venue CreateOrderBook <Admin Instruction> instrument: Carrots
  • 17. Execution Venue OrderBook <Entity> instrument: Carrots CreateOrderBook <Admin Instruction> instrument: Carrots
  • 18. PlaceOrder <Instruction> id : ABC instrument: Carrots price : 110 quantity : 5 side : BID Execution Venue OrderBook <Entity> instrument: Carrots
  • 19. PlaceOrder <Instruction> id : ABC instrument: Carrots price : 110 quantity : 5 side : BID Execution Venue OrderBook <Entity> instrument: Carrots Order <Entity> orderId : 1 id : ABC price : 110 quantity : 5 side : BID filled : 0 cancelled : 0
  • 20. PlaceOrder <Instruction> id : ABC instrument: Carrots price : 110 quantity : 5 side : BID Execution Venue OrderBook <Entity> instrument: Carrots Order <Entity> orderId : 1 id : ABC price : 110 quantity : 5 side : BID filled : 0 cancelled : 0 Accept <ExecutionReport> id : ABC LiquidityAdded <ExecutionReport> instrument: Carrots price : 110 quantity : 5
  • 21. Execution Venue OrderBook <Entity> instrument: Carrots Order <Entity> orderId : 1 id : ABC price : 110 quantity : 5 side : BID filled : 0 cancelled : 0 CancelOrder <Instruction> originalId: ABC
  • 22. Execution Venue OrderBook <Entity> instrument: Carrots CancelOrder <Instruction> originalId: ABC Cancelled <ExecutionReport> id : ABC instrument: Carrots price : 110 quantity : 5 Order <Entity> orderId : 1 id : ABC price : 110 quantity : 5 side : BID filled : 0 cancelled : 5
  • 23. Execution Venue OrderBook <Entity> instrument: Carrots CancelOrder <Instruction> originalId: ABC Cancelled <ExecutionReport> id : ABC instrument: Carrots price : 110 quantity : 5
  • 24. Execution Venue OrderBook <Entity> instrument: Carrots Order <Entity> orderId : 1 id : ABC price : 110 quantity : 5 side : BID filled : 0 cancelled : 0 PlaceOrder <Instruction> id : DEF instrument: Carrots price : 110 quantity : 5 side : ASK
  • 25. Execution Venue OrderBook <Entity> instrument: Carrots PlaceOrder <Instruction> id : DEF instrument: Carrots price : 110 quantity : 5 side : ASK Accept <ExecutionReport> id : DEF Trade <ExecutionReport> price : 110 quantity : 5 aggressive: DEF passive : ABC Order <Entity> orderId : 1 id : ABC price : 110 quantity : 5 side : BID filled : 5 cancelled : 0
  • 26. Execution Venue OrderBook <Entity> instrument: Carrots PlaceOrder <Instruction> id : DEF instrument: Carrots price : 110 quantity : 5 side : ASK Accept <ExecutionReport> id : DEF Trade <ExecutionReport> price : 110 quantity : 5 aggressive: DEF passive : ABC
  • 27. Execution Venue OrderBook <Entity> instrument: Carrots PlaceOrder <Instruction> id : ABC instrument: Bananas price : 110 quantity : 5 side : BID
  • 28. Execution Venue OrderBook <Entity> instrument: Carrots PlaceOrder <Instruction> id : ABC instrument: Bananas price : 110 quantity : 5 side : BID Reject <ExecutionReport> id : ABC
  • 29. Interesting Properties • Stable working set • Fits in memory • Doesn’t not grow monotonically with time • All decisions are made from local information
  • 30. Event-Sourced Service Journalling Replication Business Logic Message Message http://www.infoq.com/presentations/Event-Sourced-Architectures-for-High-Availability
  • 31. What did I learn • Enough understanding of the problem and solutions will appear • Pay attention to: • Entity Life-cycles • Number of entities - in real world scenarios • Try to approach the problem without bias
  • 32. If you can’t talk about the downside and the trade offs then you’re just a fan person waiving a coffee mug around. That type of behaviour really doesn’t benefit anyone. ! - Some guy on the Internet (charmalloc) Source: http://allthingshadoop.com/2013/12/06/technology-decisions-are-about-trade-offs-and-solving-problems/
  • 33. Customer Fix Gateway Load Balancer 10K msg/sec Execution Venue Market Data Service 160K msg/sec
  • 35. TIMESTAMP,BID_PRICE_1,BID_QTY_1,ASK_PRICE_1,ASK_QTY_1 1405890300827,1.35263,50,1.35296,50 1405890300908,1.35263,50,1.35296,49.9 1405890300909,1.35263,50,1.35296,47.9 1405890301090,1.35263,48.2,1.35296,47.9 1405890301193,1.35263,48.2,1.35296,46.1 1405890301194,1.35263,48.2,1.35296,44.6 1405890301280,1.35263,48.2,1.35296,42.6 1405890301571,1.35263,48.1,1.35296,42.6 1405890303037,1.35263,47.1,1.35296,42.6
  • 36. List<String[]> lines = ! parseAsList("data.csv");! for (String[] line : lines)! {! double bid = parseDouble(line[1]);! double ask = parseDouble(line[3]);! ! // Stuff...! }!
  • 37. Iterable<String[]> lines = ! parseAsIterable("data.csv");! for (String[] line : lines)! {! double bid = parseDouble(line[1]);! double ask = parseDouble(line[3]);! ! // Stuff...! }!
  • 38. public interface CsvObservable! {! default void onError(Exception e)! {! }! ! default void onComplete()! {! }! ! void onEvent(! int row, int column, ! CharSequence value, boolean endOfLine);! }
  • 39. parse("data.csv", ! (row, column, value, endOfLine) ->! {! switch (column)! {! case 1:! bid = parseDouble(value);! case 3:! ask = parseDouble(value);! }! ! // Stuff...! });
  • 40. Ops/sec GC Count GC Time (ms) Iterable 8.20 104 154 Observable 16.75 0 0
  • 41. public class CsvObservableDelegate ! implements CsvObservable<CharSequence>! {! private CsvObservable<String> delegate;! ! public CsvObservableDelegate(CsvObservable<String> delegate)! {! this.delegate = delegate;! }! ! public void onEvent(! int row, int column, ! CharSequence value, boolean endOfLine)! {! delegate.onEvent(! row, column, value.toString(), endOfLine);! }! ! // Other delegate methods! }!
  • 42. Garbage Collection Stallin’ your app since 1959
  • 43.
  • 44.
  • 45. mean 95% 99% 99.99% JDK6 1.386 1.82 5.75 15.72 JDK7 1.44 1.79 11.75 20.66
  • 46. Solutions •Don’t Generate Any • Use Zing (Azul Systems)
  • 47. Why Use Java? (why not C/C++/..)
  • 49. public class Doubles ! { ! public static void sum(! double[] sum, ! double[] addendA, ! double[] addendB)! {! for (int i = 0; i < 0 + sum.length; i++)! {! sum[i] = addendA[i] + addendB[i];! }! }! }!
  • 50. #include <immintrin.h>! ! void sum(double* c, double* a, double* b, int len)! {! __m256d rA_AVX, rB_AVX, rC_AVX;! ! for (int i = 0; i < len; i += 4)! {! rA_AVX = _mm256_load_pd(&a[i]);! rB_AVX = _mm256_load_pd(&b[i]);! rC_AVX = _mm256_add_pd(rA_AVX, rB_AVX);! _mm256_store_pd(&c[i], rC_AVX);! }! }!
  • 51.
  • 52.
  • 53. More Java vs. C++ https://github.com/real-logic/simple-binary-encoding
  • 54. What did I learn? • Details matter (performance measurement) • Let the problem define the solution • Design without bias • Understand the costs/benefits of trade-offs • Design to let others make trade-offs • Some trade-offs are not technical
  • 55. Q&A
  • 56. Links • Measuring Latency - http://goo.gl/6bllUP • Event Sourcing - http://goo.gl/VcZI7l • LMAX Architecture - http://goo.gl/UI5z0T • Source Code • http://github.com/mikeb01/qconsf2014