Java Concurrency and Performance
Java Concurrency and Performance
Training Content
4/15/2013 MOVAA Technologies Mohit Kumar
JAVA CONCURRENCY
(The most important reason for most applications(Enterprise and real-time) to fail or underperform is improper design for concurrency. This is especially true because of multi cores/processor becoming ubiquitous. This training course takes a wholistic view of concurrency including designing for multi-cores/processors(including NUMA).)
Pre-requisites: Basic knowledge of Java (introductory course or equivalent practical experience). Target Audience: The target group is programmers who want to know foundations of concurrent programming and existing concurrent programming environments, in order, now or in future, to develop multithreaded applications for multi-core processors and shared memory multiprocessors. Objective: Understand concurrency control issues in general. Know the instruments available in Java. Avoid common errors and pitfalls. Understand concurrency control idioms. What you will learn: To quickly identify the root cause of poor performance in your applications. Eliminate conditions that will prevent you from finding performance bottlenecks. Dealing with threads and collections on a multi-core/ multiprocessor. JDK 5, 6, 7 which have features to harness the power of the underlying hardware.
Producer Consumer(Basic Hand-Off) (Day:1) Common Issues with thread Java Memory Model(JMM) Applied Threading techniques Building Blocks for Highly Concurrent Design Highly Concurrent Data Structures-Part1 (Day 2) Designing For Concurrency Canned Synchronizers Highly Concurrent Data Structures-Part2 (Day 3) Crash course in Mordern hardware Concurrent Reasoning Concurrency Patterns Designing for multi-core/processor environment
locking handling done by OS Hidden queue Structural modification to hidden queue by wait-notify use cases for notify-notifyAll notifyAll used as work around design issues with synchronization
Cache Coherency
Real Meaning and effect of synchronization Volatile Final The changes in JMM
4
Wait-free Stack implementation Wait-free Queue implementation Design issues with synchronization Multiple user conditions and wait queues Lock Polling techniques Reentrant Lock
Lock Implementation
ReentrantReadWriteLock ReentrantLock
Based on CAS Lock Striping on table Lock Striping on LinkNodes. segregating them based on Thread safety levels
Lock Striping
Structure Almost immutability Using volatile to detect interference Read does not block in common code path remove/put/resize lock
For systems with more than 100 cpus/cores Constant Time key-value mapping no locks even during resize all CAS spin loop bounded faster than ConcurrentHashMap State based Reasoning
Canned Synchronizers
Queue Implementations
ConcurrentLinkedQueue LinkedBlockingQueue and LinkedBlockingDeque ArrayBlockingDeque ArrayDeque and ArrayBlockingDeque WorkStealing using Deques LinkedTransferQueue
Skiplists
ConcurrentSkipList(Map/Set)
Sequential Skiplist Lock based concurrent Skiplist Lock free concurrent Skiplist Concurrent Skiplist
7
Executor FrameWork
Configuration Hardware shapes programming idiom Exposing fine grained parallelism Divide and conquer Fork and Join Anatomy of Fork and Join Work Stealing Fork -join decomposition ParallelArray Limitations
Memory Architectures
UMA NUMA
Concurrent Reasoning
Concurrency Patterns
Fine grained Synchronization Optimistic Synchronization Lazy Synchronization Lock free Synchronization
Concurrency and Correctness Quiescent Consistency Sequential Consistency Linearizability Progress Conditions Lock suitable for NUMA systems Coarse Grained Synchronization Fine Grained Synchronization Optimistic Synchronization Lazy Synchronization Non Blocking Synchronization Bounded Partial Queue Unbounded Total Queue Unbounded lock-free Queue
9
Spinlocks
Lists
Concurrent Queues
Concurrent Stack
MOVAA Technologies | www.movaatechnologies.com
Concurrent Hashing Closed Address Hashing Open Address Hashing Lock Free Hashing Sequential Skiplist Lock based Concurrent Skiplist Lock free Skiplist Array Based bounded Priority Queue Tree based Bounded Priority Queue Heap Based Unbounded Priority Queue Skiplist based Unbounded priority Queue
Skiplist
Priority Queues
10