SlideShare uma empresa Scribd logo
1 de 19
The Pillars Of Concurrency Responsiveness  and  Isolation Throughput  and  Scalability Consistency
Pillar I – Responsiveness and Isolation UI Background Thread Background Thread ,[object Object],[object Object],Thread-Pool Thread Msg Msg Msg Msg
How?  Using BackgroundWorker ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pillar II - Throughput and Scalability ,[object Object],1KB and  more  instructions 1KB and  more  instructions 1KB and  more  instructions 1KB and  more  instructions 1KB and  more  instructions 1KB and  more  instructions Work Load OpenMP  TPL  Parallel  Studio 1KB and  more  instructions
Why? The number of transistors never stopped climbing  The Free Lunch is Over   However, clock speed stopped somewhere near 3GHz
The Solution Re-Enable the Free Lunch Use the Thread-Pool to execute your work asynchronously Add a concurrency control mechanism which will adjust the amount of work items thrown into the pool according to the workload and the machine architecture, in order to put the maximum number of cores to work with  minimum contentions How many callbacks to put in the pool? How to separate the work?
The Future  Lock-Free Thread-Pool   Instead of using a linked list, use the array-style, lock-free, GC-friendly ConcurrentQueue<T> class  The increasing number of work items and worker threads result in a problematic contention on the pool.
The Future  Work Stealing Queues When work is queued from a non-pool thread, it goes into the global queue.  Each worker thread in the pool has its own private WSQ.  When work is queued from a pool worker thread, the work goes into its WSQ, most of the time, avoiding all locking.  WSQ has two ends, it allows lock-free pushes and pops from one end (“private”), but requires synchronization from the other end (“public”)  Worker thread is being created/assigned to grab work from the global queue The worker thread grab work from its WSQ in a LIFO fashion, avoiding all locking.  Worker threads steal work from other WSQs in a FIFO fashion, synchronization is required.
The Future  Work Stealing Queues (cont) ,[object Object],[object Object],[object Object],[object Object]
The Future  Task Parallel Library ,[object Object]
The Future  Task Parallel Library ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pillar III - Consistency  ,[object Object],[object Object]
What’s the Problem?   ,[object Object]
What can we do?   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What’s the problem with Locks? ,[object Object],[object Object],[object Object],[object Object],[object Object]
What the experts suggest? ,[object Object],[object Object],[object Object]
The Future  Transactional memory ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Future  Transactional memory (cont) ,[object Object],Store reads version  Shadow copy writes Execute transaction (instead of writing into master locations – write into shadow copies) Re-execute transaction (Consider switching to pessimistic concurrency control) Copy shadow copies into their master location Update writes versions Conflict Validate reads Submit
 

Mais conteúdo relacionado

Mais procurados

Multithreading
MultithreadingMultithreading
Multithreading
sagsharma
 
Java threads
Java threadsJava threads
Java threads
javaicon
 

Mais procurados (20)

Asynchronous Python A Gentle Introduction
Asynchronous Python A Gentle IntroductionAsynchronous Python A Gentle Introduction
Asynchronous Python A Gentle Introduction
 
Introduction+To+Java+Concurrency
Introduction+To+Java+ConcurrencyIntroduction+To+Java+Concurrency
Introduction+To+Java+Concurrency
 
Threads And Synchronization in C#
Threads And Synchronization in C#Threads And Synchronization in C#
Threads And Synchronization in C#
 
Ordina SOFTC Presentation - Async CTP
Ordina SOFTC Presentation - Async CTPOrdina SOFTC Presentation - Async CTP
Ordina SOFTC Presentation - Async CTP
 
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Lecture on Java Concurrency Day 2 on Feb 4, 2009.Lecture on Java Concurrency Day 2 on Feb 4, 2009.
Lecture on Java Concurrency Day 2 on Feb 4, 2009.
 
React Hooks by Oleksandr Oleksiv Scalac
React Hooks by Oleksandr Oleksiv ScalacReact Hooks by Oleksandr Oleksiv Scalac
React Hooks by Oleksandr Oleksiv Scalac
 
Vert.x Event Driven Non Blocking Reactive Toolkit
Vert.x Event Driven Non Blocking Reactive ToolkitVert.x Event Driven Non Blocking Reactive Toolkit
Vert.x Event Driven Non Blocking Reactive Toolkit
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
 
Threading in C#
Threading in C#Threading in C#
Threading in C#
 
Real time operating systems (rtos) concepts 7
Real time operating systems (rtos) concepts 7Real time operating systems (rtos) concepts 7
Real time operating systems (rtos) concepts 7
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Containerize everything - Wildcardconf 2015
Containerize everything - Wildcardconf 2015Containerize everything - Wildcardconf 2015
Containerize everything - Wildcardconf 2015
 
Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in Java
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Java threads
Java threadsJava threads
Java threads
 
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
Concurrency Programming in Java - 06 - Thread Synchronization, Liveness, Guar...
 
Periodicalexecuter
PeriodicalexecuterPeriodicalexecuter
Periodicalexecuter
 
NodeJS
NodeJSNodeJS
NodeJS
 
Metasploit with postgresql_on_kali_linux_1.0.6
Metasploit with postgresql_on_kali_linux_1.0.6Metasploit with postgresql_on_kali_linux_1.0.6
Metasploit with postgresql_on_kali_linux_1.0.6
 
Until successful scope in mule
Until successful scope in muleUntil successful scope in mule
Until successful scope in mule
 

Semelhante a The Pillars Of Concurrency

Concurrency Learning From Jdk Source
Concurrency Learning From Jdk SourceConcurrency Learning From Jdk Source
Concurrency Learning From Jdk Source
Kaniska Mandal
 
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : NotesSpin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
Subhajit Sahu
 
Aleksandr_Butenko_Mobile_Development
Aleksandr_Butenko_Mobile_DevelopmentAleksandr_Butenko_Mobile_Development
Aleksandr_Butenko_Mobile_Development
Ciklum
 

Semelhante a The Pillars Of Concurrency (20)

Concurrency Learning From Jdk Source
Concurrency Learning From Jdk SourceConcurrency Learning From Jdk Source
Concurrency Learning From Jdk Source
 
Here comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfHere comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdf
 
Concurrency and parallel in .net
Concurrency and parallel in .netConcurrency and parallel in .net
Concurrency and parallel in .net
 
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : NotesSpin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in android
 
concurrency
concurrencyconcurrency
concurrency
 
MultiThreading in Python
MultiThreading in PythonMultiThreading in Python
MultiThreading in Python
 
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareBeyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
 
gcdtmp
gcdtmpgcdtmp
gcdtmp
 
Shopzilla On Concurrency
Shopzilla On ConcurrencyShopzilla On Concurrency
Shopzilla On Concurrency
 
Aleksandr_Butenko_Mobile_Development
Aleksandr_Butenko_Mobile_DevelopmentAleksandr_Butenko_Mobile_Development
Aleksandr_Butenko_Mobile_Development
 
Multi t hreading_14_10
Multi t hreading_14_10Multi t hreading_14_10
Multi t hreading_14_10
 
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareBeyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
 
Concurrent/ parallel programming
Concurrent/ parallel programmingConcurrent/ parallel programming
Concurrent/ parallel programming
 
Nodejs
NodejsNodejs
Nodejs
 
Demystifying the Go Scheduler
Demystifying the Go SchedulerDemystifying the Go Scheduler
Demystifying the Go Scheduler
 
The Java Memory Model
The Java Memory ModelThe Java Memory Model
The Java Memory Model
 
jvm/java - towards lock-free concurrency
jvm/java - towards lock-free concurrencyjvm/java - towards lock-free concurrency
jvm/java - towards lock-free concurrency
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/Multitasking
 
Java Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresJava Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data Structures
 

The Pillars Of Concurrency

  • 1. The Pillars Of Concurrency Responsiveness and Isolation Throughput and Scalability Consistency
  • 2.
  • 3.
  • 4.
  • 5. Why? The number of transistors never stopped climbing The Free Lunch is Over   However, clock speed stopped somewhere near 3GHz
  • 6. The Solution Re-Enable the Free Lunch Use the Thread-Pool to execute your work asynchronously Add a concurrency control mechanism which will adjust the amount of work items thrown into the pool according to the workload and the machine architecture, in order to put the maximum number of cores to work with minimum contentions How many callbacks to put in the pool? How to separate the work?
  • 7. The Future Lock-Free Thread-Pool Instead of using a linked list, use the array-style, lock-free, GC-friendly ConcurrentQueue<T> class The increasing number of work items and worker threads result in a problematic contention on the pool.
  • 8. The Future Work Stealing Queues When work is queued from a non-pool thread, it goes into the global queue. Each worker thread in the pool has its own private WSQ. When work is queued from a pool worker thread, the work goes into its WSQ, most of the time, avoiding all locking. WSQ has two ends, it allows lock-free pushes and pops from one end (“private”), but requires synchronization from the other end (“public”) Worker thread is being created/assigned to grab work from the global queue The worker thread grab work from its WSQ in a LIFO fashion, avoiding all locking. Worker threads steal work from other WSQs in a FIFO fashion, synchronization is required.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.