SlideShare una empresa de Scribd logo
1 de 37
Descargar para leer sin conexión
Trisha Gee & Michael Barker / LMAX


       The Disruptor -
       A Beginners Guide to
       Hardcore Concurrency
Sunday, 13 November 11
Why is Concurrency So Difficult
                          ?




Sunday, 13 November 11
Program Order:               Execution Order (maybe):

      int        w       =   10;   int x = 20;
      int        x       =   20;   int y = 30;
      int        y       =   30;   int b = x * y;
      int        z       =   40;
                                   int w = 10;
      int a = w + z;               int z = 40;
      int b = x * y;               int a = w + z;




Sunday, 13 November 11
Sunday, 13 November 11
Why Should We Care About the
                       Details
                         ?




Sunday, 13 November 11
static long foo = 0;

          private static void increment() {
              for (long l = 0; l < 500000000L; l++) {
                  foo++;
              }
          }




Sunday, 13 November 11
public static long foo = 0;
           public static Lock lock = new Lock();

           private static void increment() {
               for (long l = 0; l < 500000000L; l++){
                   lock.lock();
                   try {
                       foo++;
                   } finally {
                       lock.unlock();
                   }
               }
           }




Sunday, 13 November 11
static AtomicLong foo = new AtomicLong(0);

       private static void increment() {
           for (long l = 0; l < 500000000L; l++) {
               foo.getAndIncrement();
           }
       }




Sunday, 13 November 11
Cost of Contention

                  Increment a counter 500 000 000 times.

     • One Thread                      :      300 ms




Sunday, 13 November 11
Cost of Contention

                  Increment a counter 500 000 000 times.

     • One Thread                    :       300 ms
     • One Thread          (volatile):     4 700 ms    (15x)




Sunday, 13 November 11
Cost of Contention

                  Increment a counter 500 000 000 times.

     • One Thread                    :       300 ms
     • One Thread          (volatile):     4 700 ms    (15x)
     • One Thread          (Atomic) :      5 700 ms    (19x)




Sunday, 13 November 11
Cost of Contention

                  Increment a counter 500 000 000 times.

     •    One      Thread             :      300   ms
     •    One      Thread   (volatile):    4 700   ms   (15x)
     •    One      Thread   (Atomic) :     5 700   ms   (19x)
     •    One      Thread   (Lock)    :   10 000   ms   (33x)




Sunday, 13 November 11
Cost of Contention

                  Increment a counter 500 000 000 times.

     •    One      Thread              :        300   ms
     •    One      Thread    (volatile):    4   700   ms (15x)
     •    One      Thread    (Atomic) :     5   700   ms (19x)
     •    One      Thread    (Lock)    :   10   000   ms (33x)
     •    Two      Threads   (Atomic) :    30   000   ms (100x)




Sunday, 13 November 11
Cost of Contention

                  Increment a counter 500 000 000 times.

     •    One      Thread              :     300 ms
     •    One      Thread    (volatile):   4 700 ms (15x)
     •    One      Thread    (Atomic) :    5 700 ms (19x)
     •    One      Thread    (Lock)    : 10 000 ms (33x)
     •    Two      Threads   (Atomic) : 30 000 ms (100x)
     •    Two      Threads   (Lock)    : 224 000 ms (746x)
                                         ^^^^^^^^
                                      ~4 minutes!!!




Sunday, 13 November 11
Parallel v. Serial - String Split

  Guy Steele @ Strangle Loop:

  http://www.infoq.com/presentations/Thinking-Parallel-
  Programming

  Scala Implementation and Brute Force version in Java:

  https://github.com/mikeb01/folklore/




                                                 15

Sunday, 13 November 11
Parallel (Scala)          Serial (Java)

         2000.0

         1500.0

         1000.0

           500.0

                  0
                            String Split (ops/sec) higher is better


Sunday, 13 November 11
CPUs Are Getting Faster




                              17

Sunday, 13 November 11
Ya Rly!
                         P8600 (Core 2 Duo)
                         E5620 (Nehalem EP)
                         i7 2667M (Sandy Bridge ULV)
                         i7 2720QM (Sandy Bride)
      3000.0

      2250.0

      1500.0

        750.0

                0
                               String Split            18

Sunday, 13 November 11
What Problem Were Trying To Solve
                      ?




Sunday, 13 November 11
20

Sunday, 13 November 11
21

Sunday, 13 November 11
Why Queues Suck - Array Backed




                                22

Sunday, 13 November 11
Why Queues Suck - Linked List




                                    23

Sunday, 13 November 11
Why Queues Suck - Linked List




                                    24

Sunday, 13 November 11
Contention Free Design




                             25

Sunday, 13 November 11
26

Sunday, 13 November 11
How Fast Is It - Throughput
                         ABQ         Disruptor

   30000000.0

   22500000.0

   15000000.0

     7500000.0

                     0
                           Unicast        Diamond
                                                 27

Sunday, 13 November 11
How Fast Is It - Latency
                              ABQ               Disruptor

           Min                        145               29

           Mean                      32,757             52

           99 Percentile            2,097,152           128

           99.99 Percentile         4,194,304          8,192

           Max                      5,069,086         175,567



                                                                28

Sunday, 13 November 11
How Does It Work
                               ?




Sunday, 13 November 11
Ordering and Visibility
            private      static final int SIZE = 32;
            private      final Object[] data = new Object[SIZE];
            private      volatile long sequence = -1;
            private      long nextValue = -1;

            public void publish(Object value) {
                long index = ++nextValue;
                data[(int)(index % SIZE)] = value;
                sequence = index;
            }

            public Object get(long index) {
                if (index <= sequence) {
                    return data[(int)(index % SIZE)];
                }
                return null;
            }

                                                             30

Sunday, 13 November 11
Ordering and Visibility - Store
   mov    $0x1,%ecx
   add    0x18(%rsi),%rcx     ;*ladd
   ;...
   lea    (%r12,%r8,8),%r11 ;*getfield data
   ;...
   mov    %r12b,(%r11,%r10,1)
   mov    %rcx,0x10(%rsi)
   lock addl $0x0,(%rsp)      ;*ladd




                                      31

Sunday, 13 November 11
Ordering and Visibility - Load

       mov           %eax,-0x6000(%rsp)
       push          %rbp
       sub           $0x20,%rsp      ;*synchronization entry
                                     ; - RingBuffer::get@-1
       mov           0x10(%rsi),%r10    ;*getfield sequence
                                        ; - RingBuffer::get@2
       cmp           %r10,%rdx
       jl            0x00007ff92505f22d ;*iflt
                                        ; - RingBuffer::get@6
       mov           %edx,%r11d ;*l2i ; - RingBuffer::get@14




                                                        32

Sunday, 13 November 11
Look Ma’ No Memory Barrier



        AtomicLong sequence = new AtomicLong(-1);

        public void publish(Object value) {
            long index = ++nextValue;
            data[(int)(index % SIZE)] = value;
            sequence.lazySet(index);
        }




                                             33

Sunday, 13 November 11
False Sharing - Hidden Contention




                                   34

Sunday, 13 November 11
Cache Line Padding

  public class PaddedAtomicLong extends AtomicLong {

          public volatile long p1, p2, p3, p4, p5, p6 = 7L;

          //... lines omitted

          public long sumPaddingToPreventOptimisation() {
              return p1 + p2 + p3 + p4 + p5 + p6;
          }
  }




                                                   35

Sunday, 13 November 11
Summary


    •   Concurrency is a tool
    •   Ordering and visibility are the key challenges
    •   For performance the details matter
    •   Don't believe everything you read
         o Come up with your own theories and test them!




                                                  36

Sunday, 13 November 11
Q&A

                         recruitment@lmax.com




Sunday, 13 November 11

Más contenido relacionado

La actualidad más candente

スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたスマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
Taro Matsuzawa
 
Concurrency
ConcurrencyConcurrency
Concurrency
ehuard
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Paul King
 
concurrency gpars
concurrency gparsconcurrency gpars
concurrency gpars
Paul King
 

La actualidad más candente (20)

Concurrent Programming Using the Disruptor
Concurrent Programming Using the DisruptorConcurrent Programming Using the Disruptor
Concurrent Programming Using the Disruptor
 
Exploiting Concurrency with Dynamic Languages
Exploiting Concurrency with Dynamic LanguagesExploiting Concurrency with Dynamic Languages
Exploiting Concurrency with Dynamic Languages
 
Parallel Ruby: Managing the Memory Monster
Parallel Ruby: Managing the Memory MonsterParallel Ruby: Managing the Memory Monster
Parallel Ruby: Managing the Memory Monster
 
Rust: Reach Further
Rust: Reach FurtherRust: Reach Further
Rust: Reach Further
 
Linux-Permission
Linux-PermissionLinux-Permission
Linux-Permission
 
Kotlin from-scratch 3 - coroutines
Kotlin from-scratch 3 - coroutinesKotlin from-scratch 3 - coroutines
Kotlin from-scratch 3 - coroutines
 
.NET Fest 2019. Łukasz Pyrzyk. Daily Performance Fuckups
.NET Fest 2019. Łukasz Pyrzyk. Daily Performance Fuckups.NET Fest 2019. Łukasz Pyrzyk. Daily Performance Fuckups
.NET Fest 2019. Łukasz Pyrzyk. Daily Performance Fuckups
 
Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)Engineering fast indexes (Deepdive)
Engineering fast indexes (Deepdive)
 
PyTorch crash course
PyTorch crash coursePyTorch crash course
PyTorch crash course
 
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたスマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
 
Coffee Scriptでenchant.js
Coffee Scriptでenchant.jsCoffee Scriptでenchant.js
Coffee Scriptでenchant.js
 
NAS EP Algorithm
NAS EP Algorithm NAS EP Algorithm
NAS EP Algorithm
 
PyTorch Tutorial for NTU Machine Learing Course 2017
PyTorch Tutorial for NTU Machine Learing Course 2017PyTorch Tutorial for NTU Machine Learing Course 2017
PyTorch Tutorial for NTU Machine Learing Course 2017
 
CUDA Raytracing을 이용한 Voxel오브젝트 가시성 테스트
CUDA Raytracing을 이용한 Voxel오브젝트 가시성 테스트CUDA Raytracing을 이용한 Voxel오브젝트 가시성 테스트
CUDA Raytracing을 이용한 Voxel오브젝트 가시성 테스트
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Concurrecy techdrop
Concurrecy techdropConcurrecy techdrop
Concurrecy techdrop
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
 
Log
LogLog
Log
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
 
concurrency gpars
concurrency gparsconcurrency gpars
concurrency gpars
 

Similar a Beginners guide-concurrency (7)

Nachos3T
Nachos3TNachos3T
Nachos3T
 
Devon 2011-f-4-improve your-javascript
Devon 2011-f-4-improve your-javascriptDevon 2011-f-4-improve your-javascript
Devon 2011-f-4-improve your-javascript
 
Clojure night
Clojure nightClojure night
Clojure night
 
Scala Implicits - Not to be feared
Scala Implicits - Not to be fearedScala Implicits - Not to be feared
Scala Implicits - Not to be feared
 
Javascript the Language of the Web
Javascript the Language of the WebJavascript the Language of the Web
Javascript the Language of the Web
 
Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010Macruby - RubyConf Presentation 2010
Macruby - RubyConf Presentation 2010
 
Einführung in Node.js
Einführung in Node.jsEinführung in Node.js
Einführung in Node.js
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Beginners guide-concurrency

  • 1. Trisha Gee & Michael Barker / LMAX The Disruptor - A Beginners Guide to Hardcore Concurrency Sunday, 13 November 11
  • 2. Why is Concurrency So Difficult ? Sunday, 13 November 11
  • 3. Program Order: Execution Order (maybe): int w = 10; int x = 20; int x = 20; int y = 30; int y = 30; int b = x * y; int z = 40; int w = 10; int a = w + z; int z = 40; int b = x * y; int a = w + z; Sunday, 13 November 11
  • 5. Why Should We Care About the Details ? Sunday, 13 November 11
  • 6. static long foo = 0; private static void increment() { for (long l = 0; l < 500000000L; l++) { foo++; } } Sunday, 13 November 11
  • 7. public static long foo = 0; public static Lock lock = new Lock(); private static void increment() { for (long l = 0; l < 500000000L; l++){ lock.lock(); try { foo++; } finally { lock.unlock(); } } } Sunday, 13 November 11
  • 8. static AtomicLong foo = new AtomicLong(0); private static void increment() { for (long l = 0; l < 500000000L; l++) { foo.getAndIncrement(); } } Sunday, 13 November 11
  • 9. Cost of Contention Increment a counter 500 000 000 times. • One Thread : 300 ms Sunday, 13 November 11
  • 10. Cost of Contention Increment a counter 500 000 000 times. • One Thread : 300 ms • One Thread (volatile): 4 700 ms (15x) Sunday, 13 November 11
  • 11. Cost of Contention Increment a counter 500 000 000 times. • One Thread : 300 ms • One Thread (volatile): 4 700 ms (15x) • One Thread (Atomic) : 5 700 ms (19x) Sunday, 13 November 11
  • 12. Cost of Contention Increment a counter 500 000 000 times. • One Thread : 300 ms • One Thread (volatile): 4 700 ms (15x) • One Thread (Atomic) : 5 700 ms (19x) • One Thread (Lock) : 10 000 ms (33x) Sunday, 13 November 11
  • 13. Cost of Contention Increment a counter 500 000 000 times. • One Thread : 300 ms • One Thread (volatile): 4 700 ms (15x) • One Thread (Atomic) : 5 700 ms (19x) • One Thread (Lock) : 10 000 ms (33x) • Two Threads (Atomic) : 30 000 ms (100x) Sunday, 13 November 11
  • 14. Cost of Contention Increment a counter 500 000 000 times. • One Thread : 300 ms • One Thread (volatile): 4 700 ms (15x) • One Thread (Atomic) : 5 700 ms (19x) • One Thread (Lock) : 10 000 ms (33x) • Two Threads (Atomic) : 30 000 ms (100x) • Two Threads (Lock) : 224 000 ms (746x) ^^^^^^^^ ~4 minutes!!! Sunday, 13 November 11
  • 15. Parallel v. Serial - String Split Guy Steele @ Strangle Loop: http://www.infoq.com/presentations/Thinking-Parallel- Programming Scala Implementation and Brute Force version in Java: https://github.com/mikeb01/folklore/ 15 Sunday, 13 November 11
  • 16. Parallel (Scala) Serial (Java) 2000.0 1500.0 1000.0 500.0 0 String Split (ops/sec) higher is better Sunday, 13 November 11
  • 17. CPUs Are Getting Faster 17 Sunday, 13 November 11
  • 18. Ya Rly! P8600 (Core 2 Duo) E5620 (Nehalem EP) i7 2667M (Sandy Bridge ULV) i7 2720QM (Sandy Bride) 3000.0 2250.0 1500.0 750.0 0 String Split 18 Sunday, 13 November 11
  • 19. What Problem Were Trying To Solve ? Sunday, 13 November 11
  • 22. Why Queues Suck - Array Backed 22 Sunday, 13 November 11
  • 23. Why Queues Suck - Linked List 23 Sunday, 13 November 11
  • 24. Why Queues Suck - Linked List 24 Sunday, 13 November 11
  • 25. Contention Free Design 25 Sunday, 13 November 11
  • 27. How Fast Is It - Throughput ABQ Disruptor 30000000.0 22500000.0 15000000.0 7500000.0 0 Unicast Diamond 27 Sunday, 13 November 11
  • 28. How Fast Is It - Latency ABQ Disruptor Min 145 29 Mean 32,757 52 99 Percentile 2,097,152 128 99.99 Percentile 4,194,304 8,192 Max 5,069,086 175,567 28 Sunday, 13 November 11
  • 29. How Does It Work ? Sunday, 13 November 11
  • 30. Ordering and Visibility private static final int SIZE = 32; private final Object[] data = new Object[SIZE]; private volatile long sequence = -1; private long nextValue = -1; public void publish(Object value) { long index = ++nextValue; data[(int)(index % SIZE)] = value; sequence = index; } public Object get(long index) { if (index <= sequence) { return data[(int)(index % SIZE)]; } return null; } 30 Sunday, 13 November 11
  • 31. Ordering and Visibility - Store mov $0x1,%ecx add 0x18(%rsi),%rcx ;*ladd ;... lea (%r12,%r8,8),%r11 ;*getfield data ;... mov %r12b,(%r11,%r10,1) mov %rcx,0x10(%rsi) lock addl $0x0,(%rsp) ;*ladd 31 Sunday, 13 November 11
  • 32. Ordering and Visibility - Load mov %eax,-0x6000(%rsp) push %rbp sub $0x20,%rsp ;*synchronization entry ; - RingBuffer::get@-1 mov 0x10(%rsi),%r10 ;*getfield sequence ; - RingBuffer::get@2 cmp %r10,%rdx jl 0x00007ff92505f22d ;*iflt ; - RingBuffer::get@6 mov %edx,%r11d ;*l2i ; - RingBuffer::get@14 32 Sunday, 13 November 11
  • 33. Look Ma’ No Memory Barrier AtomicLong sequence = new AtomicLong(-1); public void publish(Object value) { long index = ++nextValue; data[(int)(index % SIZE)] = value; sequence.lazySet(index); } 33 Sunday, 13 November 11
  • 34. False Sharing - Hidden Contention 34 Sunday, 13 November 11
  • 35. Cache Line Padding public class PaddedAtomicLong extends AtomicLong { public volatile long p1, p2, p3, p4, p5, p6 = 7L; //... lines omitted public long sumPaddingToPreventOptimisation() { return p1 + p2 + p3 + p4 + p5 + p6; } } 35 Sunday, 13 November 11
  • 36. Summary • Concurrency is a tool • Ordering and visibility are the key challenges • For performance the details matter • Don't believe everything you read o Come up with your own theories and test them! 36 Sunday, 13 November 11
  • 37. Q&A recruitment@lmax.com Sunday, 13 November 11