You are on page 1of 104

Practicing at the Cutting Edge

Learning and Unlearning


about Performance
Martin Thompson - @mjpt777

Performance

Scalability

Java

Managed Runtimes

Learning and
Unlearning

1. Evolving Design approach

2. An evolving Hardware platform


3. Changes in Culture

1.
Evolving Design Approach

GUI Era

Battle for the Desktop

Battle for the Desktop

What was the biggest


factor in performance?

People

Reactive Designs Scale Well

Comms design is
significant to GUIs

Users love responsive interfaces

Modelling

Then the web came along

Servlets vs CGI

EJB

What do feel when you see


1 million line EJB app?

Big Data Era

What do the following


companies have in common?

Huge product catalogues

Partners

Logistics

Catalogues

Sales

PCM
Warehousing
Manufacturing

Websites
e-Procurement

Parsing

Data Management

Search

Diff

SQL too difficult?

Set Theory Rocks!

Databases are very powerful!

Immutable Data Rocks!

JDBC Drivers Suck!!!

Stream Processing Rocks!

But!

API design is key

public void startElement(String uri,


String localName,
String qName,
Attributes atts)
throws SAXException

public void startElement(String uri,


String localName,
String qName,
Attributes atts)
throws SAXException

public void characters(char[] ch,


int start,
int length)
throws SAXException

public String[] split(String regex)

public String[] split(String regex)

public Iterable<String> split(String regex)

public String[] split(String regex)

public Iterable<String> split(String regex)

public void split(String regex,


Collection<String> dst)

Modelling

Design Paradigms

Different

Same

Different

Transaction
Processing
Era

Synchronous Designs are Limited

Staged Event Driven Architecture

The importance of Latency

Latency

Latency given Throughput

Load

The issues with Concurrency

The Disruptor

The value of Determinism

The value of pure Functions

Modelling

Design Paradigms
Different

Different
Same
Different

2.
Evolving Platform

All Storage is Tape

Networks are faster than


Storage

Memory Access Patterns Matter

What if you could build a HashMap


with reified generics
and arrays of structures?

Buckets

Bob
Buckets

A1

Key

Value Hash Next

Bob
Buckets

A1

Key

Value Hash Next

Key

Value Hash Next

FF

Jim

Bob
Buckets

A1
C7
Fred
Key

Value Hash Next


Key

Key

Value Hash Next

FF

Jim

Value Hash Next

Buckets

Key

Value

Hash

Next

Buckets

Key

Value

Hash

Next

A1

Bob

-1

Buckets

Key

Value

Hash

Next

A1

Bob

-1

C7

Fred

-1

Buckets

Key

Value

Hash

Next

A1

Bob

C7

Fred

-1

FF

Jim

-1

.Net Dictionary is 10X faster


than HashMap for 2GB of data

Value Types (Arrays 2.064)


ObjectLayout

PackedObjects

Amdahls Law

Garbage Collection?

Stop The World GC

Potential Throughput given % Serial STW GC


100%
90%

Possible Throughput

80%
70%
60%

50%
40%
30%
20%
10%
0%

2.00%
5.00%
10.00%

Safepoints!!!

Persistent Data Structures

HAMT

*
Market
HAMT

*
Venue
HAMT

*
Instrument
HAMT

*
Order

Ref

HAMT

*
Market
HAMT

*
Venue
HAMT

*
Instrument
HAMT

*
Order

<< CAS Failure? >>


Ref

HAMT

<< CAS Failure? >>


Ref

*
Market
HAMT

*
Venue

Threads

*
Instrument
HAMT

*
Order

Model Depth

HAMT

Shared Nothing to Scale

Think Transputers
but with
messaging
passing via SHM

3.
Changes in Culture

Measure Everything

Continuous Profiling

Mechanical Sympathy

What have I learned that is


really important?

Research

Experiment

Collaborate

Questions?
Blog: http://mechanical-sympathy.blogspot.com/

Twitter: @mjpt777
It does not matter how intelligent you are,
if you guess and that guess cannot be backed
up by experimental evidence then it is still a guess.
- Richard Feynman

You might also like