Scale Up with Lock-Free Algorithms. Non-blocking concurrency on JVM Presented at JavaOne 2017 /Roman JetBrains
|
|
- Loreen Golden
- 5 years ago
- Views:
Transcription
1 Scale Up with Lock-Free Algorithms Non-blocking concurrency on JVM Presented at JavaOne 2017 /Roman JetBrains
2 Speaker: Roman Elizarov 16+ years experience Previously developed high-perf trading Devexperts Teach concurrent & distributed St. Petersburg ITMO University Chief Northern Eurasia Contest / ACM ICPC Now work on JetBrains
3 Shared
4 Shared Mutable
5 Shared Mutable State
6
7
8 Shared Mutable State Why?
9 Big Big Data
10 Data 1 Data 2 Data N
11 Data 1 Data 2 Data N map map map
12 Data 1 Data 2 Data N map map map reduce answer
13 Embarrassingly parallel Data 1 Data 2 Data N map map map reduce answer
14 Big Big Data
15 Big Big Data Real-time
16 Big Big Data Real-time Concurrent requests / processing
17 Big Big Data Real-time Concurrent requests / processing Performance Scalability
18
19 A toy problem
20 A toy problem stack
21 A toy problem stack class Node<T>(val next: Node<T>?, val value: T)
22 A toy problem stack public final class Node<T> { private final Node<T> next; private final T value; public Node(Node<T> next, T value) { this.next = next; this.value = value; public Node<T> getnext() { return next; public T getvalue() { return value;
23 A toy problem stack class Node<T>(val next: Node<T>?, val value: T)
24 A toy problem empty stack class Node<T>(val next: Node<T>?, val value: T) top
25 A toy problem stack push class Node<T>(val next: Node<T>?, val value: T) top А next = null value = 1
26 A toy problem stack push class Node<T>(val next: Node<T>?, val value: T) top А next = null value = 1 B next = A value = 2
27 A toy problem stack push class Node<T>(val next: Node<T>?, val value: T) top А next = null value = 1 B next = A value = 2
28 A toy problem stack push class Node<T>(val next: Node<T>?, val value: T) top B next = A value = 2 A next = null value = 1
29 A toy problem stack push class Node<T>(val next: Node<T>?, val value: T) class LinkedStack<T> { private var top: Node<T>? = null fun push(value: T) { top = Node(top, value)
30 A toy problem stack push class Node<T>(val next: Node<T>?, val value: T) class LinkedStack<T> { private var top: Node<T>? = null fun push(value: T) { top = Node(top, value)
31 A toy problem stack push class Node<T>(val next: Node<T>?, val value: T) class LinkedStack<T> { private var top: Node<T>? = null fun push(value: T) { top = Node(top, value)
32 A toy problem stack class Node<T>(val next: Node<T>?, val value: T) top B next = A value = 2 A next = null value = 1
33 A toy problem stack pop class Node<T>(val next: Node<T>?, val value: T) top B next = A value = 2 A next = null value = 1 cur
34 A toy problem stack pop class Node<T>(val next: Node<T>?, val value: T) top B next = A value = 2 A next = null value = 1 cur
35 A toy problem stack pop class Node<T>(val next: Node<T>?, val value: T) top B next = A value = 2 A next = null value = 1 cur result = 2
36 A toy problem stack pop class Node<T>(val next: Node<T>?, val value: T) class LinkedStack<T> { private var top: Node<T>? = null fun push(value: T) { top = Node(top, value) fun pop(): T? { val cur = top?: return null top = cur.next return cur.value
37 A toy problem stack class Node<T>(val next: Node<T>?, val value: T) class LinkedStack<T> { private var top: Node<T>? = null fun push(value: T) { top = Node(top, value) fun pop(): T? { val cur = top?: return null top = cur.next return cur.value
38 Does it work?
39 A toy problem concurrent push class Node<T>(val next: Node<T>?, val value: T) top А next = null value = 1 B next = A value = 2
40 A toy problem concurrent push class Node<T>(val next: Node<T>?, val value: T) top А next = null value = 1 B C next = A value = 2 next = A value = 3
41 A toy problem concurrent push class Node<T>(val next: Node<T>?, val value: T) top А next = null value = 1 B C next = A value = 2 next = A value = 3
42 A toy problem synchronized stack class Node<T>(val next: Node<T>?, val value: T) class LinkedStack<T> { private var top: Node<T>? = fun push(value: T) { top = Node(top, fun pop(): T? { val cur = top?: return null top = cur.next return cur.value
43 Does it scale?
44 open class LinkedStackBenchmark { private val stack = fun benchmark() { stack.push(1) check(stack.pop() == 1)
45 open class LinkedStackBenchmark { private val stack = fun benchmark() { stack.push(1) check(stack.pop() == 1)
46 Benchmark results Throughput (ops/s) Millions LinkedStack Number of threads Intel(R) Xeon(R) CPU E GHz; 32 HW threads; Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
47 Contention P pop 1 Q
48 Contention P pop 1 Q
49 Contention P pop 1 Q pop 2 wait
50 Contention P pop 1 Q pop 2 wait work
51 Deadlocks
52 Lock-free?
53 Lock-free push class Node<T>(val next: Node<T>?, val value: T) top expect А next = null value = 1 B next = A value = 2
54 Lock-free push class Node<T>(val next: Node<T>?, val value: T) top А next = null value = 1 update B next = A value = 2
55 Lock-free push class Node<T>(val next: Node<T>?, val value: T) top expect update А next = null value = 1 B next = A value = 2
56 AtomicReference package java.util.concurrent.atomic; 1.5 */ public class AtomicReference<V> { private volatile V value; public V get() { return value; public boolean compareandset(v expect, V update) { //
57 AtomicReference package java.util.concurrent.atomic; 1.5 */ public class AtomicReference<V> { private volatile V value; public V get() { return value; public boolean compareandset(v expect, V update) { //
58 AtomicReference package java.util.concurrent.atomic; 1.5 */ public class AtomicReference<V> { private volatile V value; public V get() { return value; public boolean compareandset(v expect, V update) { //
59 Using AtomicReference class LockFree<T> { private val top = AtomicReference<Node<T>?>(null) fun push(value: T) { while (true) { val cur = top.get() val upd = Node(cur, value) if (top.compareandset(cur, upd)) return
60 Using AtomicReference class LockFree<T> { private val top = AtomicReference<Node<T>?>(null) fun push(value: T) { while (true) { val cur = top.get() val upd = Node(cur, value) if (top.compareandset(cur, upd)) return
61 Using AtomicReference - push class LockFree<T> { private val top = AtomicReference<Node<T>?>(null) fun push(value: T) { while (true) { 1 val cur = top.get() val upd = Node(cur, value) if (top.compareandset(cur, upd)) return
62 Using AtomicReference - push class LockFree<T> { private val top = AtomicReference<Node<T>?>(null) fun push(value: T) { while (true) { 1 val cur = top.get() 2 val upd = Node(cur, value) if (top.compareandset(cur, upd)) return
63 Using AtomicReference class LockFree<T> { private val top = AtomicReference<Node<T>?>(null) fun push(value: T) { while (true) { 1 val cur = top.get() 2 val upd = Node(cur, value) 3 if (top.compareandset(cur, upd)) return
64 Using AtomicReference - push class LockFree<T> { private val top = AtomicReference<Node<T>?>(null) fun push(value: T) { while (true) { 1 val cur = top.get() 2 val upd = Node(cur, value) 3 if (top.compareandset(cur, upd)) return
65 Powerful we have become!
66 Using AtomicReference - pop class LockFree<T> { private val top = AtomicReference<Node<T>?>(null) fun push(value: T) { fun pop(): T? { while (true) { val cur = top.get()?: return null if (top.compareandset(cur, cur.next)) return cur.value
67 Using AtomicReference class LockFree<T> { private val top = AtomicReference<Node<T>?>(null) fun push(value: T) { fun pop(): T? {
68 It s a trap
69 Using volatile variable class LinkedStackLF<T> private var top: Node<T>? = null fun push(value: T) { //...
70 Using AtomicReferenceFieldUpdater package java.util.concurrent.atomic; 1.5 */ public abstract class AtomicReferenceFieldUpdater<T,V> { public static <U,W> AtomicReferenceFieldUpdater<U,W> newupdater( Class<U> tclass, Class<W> vclass, String fieldname; public abstract boolean compareandset(t obj, V expect, V update;
71 Using AtomicReferenceFieldUpdater private volatile Node<T> top;
72 Using AtomicReferenceFieldUpdater private volatile Node<T> top; private static final AtomicReferenceFieldUpdater<LockFree, Node> TOP = AtomicReferenceFieldUpdater.newUpdater(LockFree.class, Node.class, "top");
73 Using AtomicReferenceFieldUpdater private volatile Node<T> top; private static final AtomicReferenceFieldUpdater<LockFree, Node> TOP = AtomicReferenceFieldUpdater.newUpdater(LockFree.class, Node.class, "top"); if (TOP.compareAndSet(this, cur, upd)) return;
74 Using VarHandle package java.lang.invoke; 9 */ public abstract class VarHandle public native boolean compareandset(object... args);
75 Using VarHandle private volatile Node<T> top; private static final VarHandle TOP; static { try { TOP = MethodHandles.lookup().findVarHandle(LockFree.class, "top", Node.class); catch (NoSuchFieldException IllegalAccessException e) { throw new InternalError(e);
76 Using VarHandle private volatile Node<T> top; private static final VarHandle TOP; static { try { TOP = MethodHandles.lookup().findVarHandle(LockFree.class, "top", Node.class); catch (NoSuchFieldException IllegalAccessException e) { throw new InternalError(e); if (TOP.compareAndSet(this, cur, upd) return;
77 Using AtomicFU J private val top = atomic<node<t>?>(null)
78 Using AtomicFU J private val top = atomic<node<t>?>(null) if (top.compareandset(cur, upd)) return
79 Using AtomicFU J private val top = atomic<node<t>?>(null) if (top.compareandset(cur, upd)) return Code like AtomicReference
80 Using AtomicFU J private val top = atomic<node<t>?>(null) if (top.compareandset(cur, upd)) return Code like AtomicReference compile Bytecode
81 Using AtomicFU J private val top = atomic<node<t>?>(null) if (top.compareandset(cur, upd)) return Code like AtomicReference compile Bytecode atomicfu AtomicReferenceFU
82 Using AtomicFU J private val top = atomic<node<t>?>(null) if (top.compareandset(cur, upd)) return Code like AtomicReference compile Bytecode atomicfu VarHandle
83 Was it worth it?
84 Benchmark results Throughput (ops/s) Millions LockFree LinkedStack Number of threads
85 Benchmark results Millions Yeh! Throughput (ops/s) Nay LockFree LinkedStack Number of threads
86 Contention P pop 1 Q pop 2 try update retry
87 Too toy of a problem? class LinkedStack<T> { private var top: Node<T>? = fun push(value: T) fun pop(): T? { val cur = top?: return null top = cur.next return cur.value
88 Too toy of a problem make it more real? class LinkedStack<T> { private var top: Node<T>? = fun push(value: T) fun pop(): T? { val cur = top?: return null top = cur.next Blackhole.consumeCPU(100L) return cur.value
89 Too toy of a problem make it more real? class LockFree<T> { private val top = atomic<node<t>?>(null) fun push(value: T) { fun pop(): T? { while (true) { val cur = top.value?: return null Blackhole.consumeCPU(100L) if (top.compareandset(cur, cur.next)) return cur.value
90 Benchmark results Millions Throughput (ops/s) Number of threads LockFree LinkedStack
91 open class LinkedStackBenchmark { private val stack = fun benchmark() { stack.push(1) check(stack.pop() == 1)
92 Read-dominated open class LinkedStackBenchmark { private val stack = fun benchmarkreaddominated() { stack.push(1) repeat(10) { check(stack.peek() == 1) check(stack.pop() == 1)
93 Read-dominated open class LinkedStackBenchmark { private val stack = fun benchmarkreaddominated() { stack.push(1) repeat(10) { check(stack.peek() == 1) check(stack.pop() == 1) class LinkedStack<T> fun peek() = top?.value
94 Read-dominated open class LockFreeBenchmark { private val stack = fun benchmarkreaddominated() { stack.push(1) repeat(10) { check(stack.peek() == 1) check(stack.pop() == 1) class LockFree<T> { fun peek() = top.value?.value
95 Benchmark results x10 reads Throughput (ops/s) Millions LockFree LinkedStack Number of threads
96 Benchmark results x100 reads Throughput (ops/s) Millions LockFree LinkedStack Number of threads
97 But scalability?
98 Real-world fun benchmarkreadworld() { stack.push(1) repeat(10) { check(stack.peek() == 1) Blackhole.consumeCPU(100L) check(stack.pop() == 1) Blackhole.consumeCPU(100L)
99 Benchmark results real world Throughput (ops/s) Millions Number of threads LockFree LinkedStack
100 Learn to ask the right questions You shall, young Padawan.
101
102 Links JMH Kotlin AtomicFU
103 Thank you Any questions? Slides are available at me to elizarov at gmail relizarov
104 Appendix
105 A toy problem concurrent pop class Node<T>(val next: Node<T>?, val value: T) top B next = A value = 2 A next = null value = 1 cur 1 cur 2
106 A toy problem concurrent pop class Node<T>(val next: Node<T>?, val value: T) top B next = A value = 2 A next = null value = 1 cur 1 cur 2
107 A toy problem concurrent pop class Node<T>(val next: Node<T>?, val value: T) top B next = A value = 2 A next = null value = 1 cur 1 cur 2 result 1 = 2 result 2 = 2
Fresh Async With Kotlin. Presented at QCon SF, 2017 /Roman JetBrains
Fresh Async With Kotlin Presented at QCon SF, 2017 /Roman Elizarov @ JetBrains Speaker: Roman Elizarov 16+ years experience Previously developed high-perf trading software @ Devexperts Teach concurrent
More informationCMPSCI 187: Programming With Data Structures. Lecture 12: Implementing Stacks With Linked Lists 5 October 2011
CMPSCI 187: Programming With Data Structures Lecture 12: Implementing Stacks With Linked Lists 5 October 2011 Implementing Stacks With Linked Lists Overview: The LinkedStack Class from L&C The Fields and
More informationLock-free algorithms for Kotlin coroutines. It is all about scalability Presented at SPTCC 2017 /Roman JetBrains
Lock-free algorithms for Kotlin coroutines It is all about scalability resented at TCC 2017 /Roman Elizarov @ JetBrains peaker: Roman Elizarov 16+ years experience reviously developed high-perf trading
More informationParsing Scheme (+ (* 2 3) 1) * 1
Parsing Scheme + (+ (* 2 3) 1) * 1 2 3 Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply + Compiling Scheme make-return START make-test make-close make-assign make- pair? yes
More informationAdvanced concurrent programming in Java Shared objects
Advanced concurrent programming in Java Shared objects Mehmet Ali Arslan 21.10.13 Visibility To see(m) or not to see(m)... 2 There is more to synchronization than just atomicity or critical sessions. Memory
More informationProgramming Language Seminar Concurrency 2: Lock-free algorithms
Programming Language Seminar Concurrency 2: Lock-free algorithms Peter Sestoft Friday 2013-11-01 1 Outline for today Compare-and-swap instruction Atomic test-then-set operation Implemented directly in
More informationIntroduction to Coroutines. Roman Elizarov elizarov at JetBrains
Introduction to Coroutines Roman Elizarov elizarov at JetBrains Asynchronous programming How do we write code that waits for something most of the time? A toy problem Kotlin 1 fun requesttoken(): Token
More informationIntroduction to Computer Science II (ITI 1121) Midterm Examination
Introduction to Computer Science II (ITI 1121) Midterm Examination Instructor: Marcel Turcotte February 2008, duration: 2 hours Identification Student name: Student number: Signature: Instructions 1. 2.
More informationA Deep Dive Into Kotlin
A Deep Dive Into Kotlin By 1 About me (droidyue.com) @Flipboard China GDG 2 3 Kotlin An official language for Android recently Powered by Jetbrains 4 Why Kotlin Concise Safe interoperable tool-friendly
More informationOutline. Example stack Version 1 -- int stack with fixed array Version 2 -- int stack with flexible array Version 3 -- with interface
Outline Example stack Version 1 -- int stack with fixed array Version 2 -- int stack with flexible array Version 3 -- with interface Visibility issues 6 :: 2 0024 Spring 2010 Stacks push(value) -- store
More informationCMSC 132: Object-Oriented Programming II. Stack and Queue
CMSC 132: Object-Oriented Programming II Stack and Queue 1 Stack Allows access to only the last item inserted. An item is inserted or removed from the stack from one end called the top of the stack. This
More informationHardware Support for a Wireless Sensor Network Virtual Machine
Hardware Support for a Wireless Sensor Network Virtual Machine Hitoshi Oi The University of Aizu February 13, 2008 Mobilware 2008, Innsbruck, Austria Outline Introduction to the Wireless Sensor Network
More informationAtomic Variables & Nonblocking Synchronization
Atomic Variables & Nonblocking Synchronization CMSC 433 Fall 2014 Michael Hicks (with some slides due to Rance Cleaveland) A Locking Counter public final class Counter { private long value = 0; public
More informationCMSC 433 Programming Language Technologies and Paradigms. Sharing Objects
CMSC 433 Programming Language Technologies and Paradigms Sharing Objects Administrivia Are you getting your money s worth? Are you reviewing the slides? Are you experimenting with concurrency? Have you
More informationPractical Concurrent and Parallel Programming 10
Practical Concurrent and Parallel Programming 10 Peter Sestoft IT University of Copenhagen Friday 2016-11-11* IT University of Copenhagen 1 Plan for today Compare and swap (CAS) low-level atomicity Examples:
More informationLinked Structures - Review Chapter 13. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013
Linked Structures - Review Chapter 13 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Scope Introduction to Linked Structures: Object references as links Linked vs. array-based structures
More informationMethodHandle implemention tips and tricks
MethodHandle implemention tips and tricks Dan Heidinga J9 VM Software Developer daniel_heidinga@ca.ibm.com J9 Virtual Machine 2011 IBM Corporation MethodHandles: a 30 sec introduction A method handle is
More informationIntroduction Basics Concurrency Conclusion. Clojure. Marcel Klinzing. December 13, M. Klinzing Clojure 1/18
Clojure Marcel Klinzing December 13, 2012 M. Klinzing Clojure 1/18 Overview/History Functional programming language Lisp dialect Compiles to Java Bytecode Implemented in Java Created by Rich Hickey Version
More information+ Today. Lecture 26: Concurrency 3/31/14. n Reading. n Objectives. n Announcements. n P&C Section 7. n Race conditions.
+ Lecture 26: Concurrency Slides adapted from Dan Grossman + Today n Reading n P&C Section 7 n Objectives n Race conditions n Announcements n Quiz on Friday 1 + This week s programming assignment n Answer
More informationScala Actors. Scalable Multithreading on the JVM. Philipp Haller. Ph.D. candidate Programming Methods Lab EPFL, Lausanne, Switzerland
Scala Actors Scalable Multithreading on the JVM Philipp Haller Ph.D. candidate Programming Methods Lab EPFL, Lausanne, Switzerland The free lunch is over! Software is concurrent Interactive applications
More informationConcurrency and High Performance Reloaded
Concurrency and High Performance Reloaded Disclaimer Any performance tuning advice provided in this presentation... will be wrong! 2 www.kodewerk.com Me Work as independent (a.k.a. freelancer) performance
More informationA Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections
A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections Dan Grossman Last Updated: May 2012 For more information, see http://www.cs.washington.edu/homes/djg/teachingmaterials/
More informationMultitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit
Threads Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multitasking Thread-based multitasking Multitasking
More informationStacks have many uses Arithmetic Language parsing Keeping track of recursion (more in this in a week or so)
Implementing Stacks Basics of Exceptions OK, so stacks are useful Stacks have many uses Arithmetic Language parsing Keeping track of recursion (more in this in a week or so) How can stacks be implemented?
More informationCMP Points Total Midterm Spring Version (16 Points) Multiple Choice:
CMP-338 106 Points Total Midterm Spring 2017 Version 1 Instructions Write your name and version number on the top of the yellow paper. Answer all questions on the yellow paper. One question per page. Use
More informationUsing Java 8 Lambdas And Stampedlock To Manage Thread Safety
1 Using Java 8 Lambdas And Stampedlock To Manage Thread Safety Dr Heinz M. Kabutz heinz@javaspecialists.eu Last updated 2017-05-09 2013-2017 Heinz Kabutz All Rights Reserved 2 Why Should You Care About
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2013
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2013 Name: This exam consists of 5 problems on the following 6 pages. You may use your double-sided hand-written 8 ½ x 11 note sheet
More informationProgramming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI
Programming Kotlin Familiarize yourself with all of Kotlin s features with this in-depth guide Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Copyright 2017 Packt Publishing First
More informationIT 4043 Data Structures and Algorithms
IT 4043 Data Structures and Algorithms Budditha Hettige Department of Computer Science 1 Syllabus Introduction to DSA Abstract Data Types Arrays List Operation Using Arrays Recursion Stacks Queues Link
More informationGetting Started with Kotlin. Commerzbank Java Developer Day
Getting Started with Kotlin Commerzbank Java Developer Day 30.11.2017 Hello! Alexander Hanschke Hello! Alexander Hanschke CTO at techdev Solutions GmbH in Berlin Hello! Alexander Hanschke CTO at techdev
More informationBasic Data Structures
Basic Data Structures Some Java Preliminaries Generics (aka parametrized types) is a Java mechanism that enables the implementation of collection ADTs that can store any type of data Stack s1
More informationCSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections. Tyler Robison Summer 2010
CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections Tyler Robison Summer 2010 1 Concurrency: where are we Done: The semantics of locks Locks in Java Using locks for mutual
More informationBasic Data Structures 1 / 24
Basic Data Structures 1 / 24 Outline 1 Some Java Preliminaries 2 Linked Lists 3 Bags 4 Queues 5 Stacks 6 Performance Characteristics 2 / 24 Some Java Preliminaries Generics (aka parametrized types) is
More informationManaged runtimes & garbage collection
Managed runtimes Advantages? Managed runtimes & garbage collection CSE 631 Some slides by Kathryn McKinley Disadvantages? 1 2 Managed runtimes Portability (& performance) Advantages? Reliability Security
More informationManaged runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley
Managed runtimes & garbage collection CSE 6341 Some slides by Kathryn McKinley 1 Managed runtimes Advantages? Disadvantages? 2 Managed runtimes Advantages? Reliability Security Portability Performance?
More information"Object Oriented" Programming using ML
"Object Oriented" Programming using ML Stavros Aronis (based on slides by Kostis Sagonas) http://courses.softlab.ntua.gr/pl1/2008a/slides/lecture-13-bw.pdf OOP Terminology Class Inheritance Encapsulation
More informationAdvances in Programming Languages
O T Y H Advances in Programming Languages APL5: Further language concurrency mechanisms David Aspinall (including slides by Ian Stark) School of Informatics The University of Edinburgh Tuesday 5th October
More informationScala Concurrency and Parallel Collections
Scala Concurrency and Parallel Collections Concurrent Programming Keijo Heljanko Department of Computer Science University School of Science November 23rd, 2016 Slides by Keijo Heljanko Scala Scala Originally
More informationLab. Lecture 26: Concurrency & Responsiveness. Assignment. Maze Program
Lab Lecture 26: Concurrency & Responsiveness CS 62 Fall 2016 Kim Bruce & Peter Mawhorter Using parallelism to speed up sorting using Threads and ForkJoinFramework Review relevant material. Some slides
More informationProblems with Concurrency. February 19, 2014
with Concurrency February 19, 2014 s with concurrency interleavings race conditions dead GUI source of s non-determinism deterministic execution model 2 / 30 General ideas Shared variable Access interleavings
More informationJAVA PERFORMANCE. PR SW2 S18 Dr. Prähofer DI Leopoldseder
JAVA PERFORMANCE PR SW2 S18 Dr. Prähofer DI Leopoldseder OUTLINE 1. What is performance? 1. Benchmarking 2. What is Java performance? 1. Interpreter vs JIT 3. Tools to measure performance 4. Memory Performance
More information3/25/14. Lecture 25: Concurrency. + Today. n Reading. n P&C Section 6. n Objectives. n Concurrency
+ Lecture 25: Concurrency + Today n Reading n P&C Section 6 n Objectives n Concurrency 1 + Concurrency n Correctly and efficiently controlling access by multiple threads to shared resources n Programming
More informationSafely Shoot Yourself in the Foot with Java 9
1 Safely Shoot Yourself in the Foot with Java 9 Dr Heinz M. Kabutz Last Updated 2017-11-04 2 Project Jigsaw: Primary Goals (Reinhold)! Make the Java SE Platform, and the JDK, more easily scalable down
More informationCS 310: Array- and Linked-based Data Structures
CS 310: Array- and Linked-based Data Structures Chris Kauffman Week 3-2 Logistics At Home Read Weiss Ch 15: ArrayList implementation Read Weiss Ch 16: Stacks and Queues implementation HW 1: Due Sunday
More informationSafely Shoot Yourself in the Foot with Java 9 Dr Heinz M. Kabutz
Safely Shoot Yourself in the Foot with Java 9 Dr Heinz M. Kabutz Last Updated 2017-11-08 Project Jigsaw: Primary Goals (Reinhold) Make the Java SE Platform, and the JDK, more easily scalable down to small
More informationThreads and Java Memory Model
Threads and Java Memory Model Oleg Šelajev @shelajev oleg@zeroturnaround.com October 6, 2014 Agenda Threads Basic synchronization Java Memory Model Concurrency Concurrency - several computations are executing
More informationThe list abstract data type defined a number of operations that all list-like objects ought to implement:
Chapter 7 Polymorphism Previously, we developed two data structures that implemented the list abstract data type: linked lists and array lists. However, these implementations were unsatisfying along two
More informationIT 4043 Data Structures and Algorithms. Budditha Hettige Department of Computer Science
IT 4043 Data Structures and Algorithms Budditha Hettige Department of Computer Science 1 Syllabus Introduction to DSA Abstract Data Types List Operation Using Arrays Stacks Queues Recursion Link List Sorting
More informationComputer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print)
Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 SOLUTIONS Your name (Please print) 1. Suppose you are given a singly-linked
More informationECE 587 Hardware/Software Co-Design Lecture 07 Concurrency in Practice Shared Memory I
ECE 587 Hardware/Software Co-Design Spring 2018 1/15 ECE 587 Hardware/Software Co-Design Lecture 07 Concurrency in Practice Shared Memory I Professor Jia Wang Department of Electrical and Computer Engineering
More informationEffective Concurrent Java. Brian Goetz Sr. Staff Engineer, Sun Microsystems
Effective Concurrent Java Brian Goetz Sr. Staff Engineer, Sun Microsystems brian.goetz@sun.com The Big Picture Writing correct concurrent code is difficult, but not impossible. Using good object-oriented
More informationCOMP31212: Concurrency A Review of Java Concurrency. Giles Reger
COMP31212: Concurrency A Review of Java Concurrency Giles Reger Outline What are Java Threads? In Java, concurrency is achieved by Threads A Java Thread object is just an object on the heap, like any other
More informationRaces. Example. A race condi-on occurs when the computa-on result depends on scheduling (how threads are interleaved)
Races A race condi-on occurs when the computa-on result depends on scheduling (how threads are interleaved) Bugs that exist only due to concurrency o No interleaved scheduling with 1 thread Typically,
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationCS24 Week 4 Lecture 2
CS24 Week 4 Lecture 2 Kyle Dewey Overview Linked Lists Stacks Queues Linked Lists Linked Lists Idea: have each chunk (called a node) keep track of both a list element and another chunk Need to keep track
More informationPerformance Profiling. Curtin University of Technology Department of Computing
Performance Profiling Curtin University of Technology Department of Computing Objectives To develop a strategy to characterise the performance of Java applications benchmark to compare algorithm choices
More informationVoltDB vs. Redis Benchmark
Volt vs. Redis Benchmark Motivation and Goals of this Evaluation Compare the performance of several distributed databases that can be used for state storage in some of our applications Low latency is expected
More informationJava theory and practice: Going atomic The new atomic classes are the hidden gems of java.util.concurrent
1 of 8 Java theory and practice: Going atomic The new atomic classes are the hidden gems of java.util.concurrent Level: Intermediate Brian Goetz (brian@quiotix.com), Principal Consultant, Quiotix 23 Nov
More informationBugs in software. Using Static Analysis to Find Bugs. David Hovemeyer
Bugs in software Programmers are smart people We have good techniques for finding bugs early: Unit testing, pair programming, code inspections So, most bugs should be subtle, and require sophisticated
More informationThe Actor Model. Towards Better Concurrency. By: Dror Bereznitsky
The Actor Model Towards Better Concurrency By: Dror Bereznitsky 1 Warning: Code Examples 2 Agenda Agenda The end of Moore law? Shared state concurrency Message passing concurrency Actors on the JVM More
More informationIntroduction to Computing II (ITI 1121) FINAL EXAMINATION
Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of Engineering School of Electrical Engineering and Computer Science Identification
More informationSpring 2018 Discussion 6: February 19, 2018
CS 61B Selecting ADTs Spring 2018 Discussion 6: February 19, 2018 1 Immutable Rocks Access control allows us to restrict the use of fields, methods, and classes. public: Accessible by everyone. protected:
More informationScaling the OpenJDK. Claes Redestad Java SE Performance Team Oracle. Copyright 2017, Oracle and/or its afliates. All rights reserved.
Scaling the OpenJDK Claes Redestad Java SE Performance Team Oracle Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only,
More informationConcurrent Programming using Threads
Concurrent Programming using Threads Threads are a control mechanism that enable you to write concurrent programs. You can think of a thread in an object-oriented language as a special kind of system object
More informationGenerics in Java. EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG
Generics in Java EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG Motivating Example: A Book of Objects 1 class Book { 2 String[] names; 3 Object[] records; 4 /* add a name-record
More informationMotivating Example: Observations (1) Generics in Java. Motivating Example: A Book of Objects. Motivating Example: Observations (2)
Motivating Example: Observations (1) Generics in Java EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG In the Book class: By declaring the attribute Object[] records We meant that
More informationBenchmarking/Profiling (In)sanity
Benchmarking/Profiling (In)sanity It all started when I stumbled upon AppendableWriter in guava which is nothing more than an adapter class that adapts an Appendable to a Writer. When looking over the
More informationStacks and Queues. David Greenstein Monta Vista
Stacks and Queues David Greenstein Monta Vista Stack vs Queue Stacks and queues are used for temporary storage, but in different situations Stacks are Used for handling nested structures: processing directories
More informationSpecialization of Java Generic Types
Specialization of Java Generic Types Sam BeVier, Elena Machkasova University of Minnesota, Morris July 17, 2006 Contents 1 Overview 1 1.1 Introduction.............................. 1 1.2 Specializing Type
More informationRecap. Contents. Reenterancy of synchronized. Explicit Locks: ReentrantLock. Reenterancy of synchronise (ctd) Advanced Thread programming.
Lecture 07: Advanced Thread programming Software System Components 2 Behzad Bordbar School of Computer Science, University of Birmingham, UK Recap How to deal with race condition in Java Using synchronised
More informationDesigning for Scalability. Patrick Linskey EJB Team Lead BEA Systems
Designing for Scalability Patrick Linskey EJB Team Lead BEA Systems plinskey@bea.com 1 Patrick Linskey EJB Team Lead at BEA OpenJPA Committer JPA 1, 2 EG Member 2 Agenda Define and discuss scalability
More informationBackground. Reflection. The Class Class. How Objects Work
Background Reflection Turing's great insight: programs are just another kind of data Source code is text Manipulate it line by line, or by parsing expressions Compiled programs are data, too Integers and
More informationSharing is the Key. Lecture 25: Parallelism. Canonical Example. Bad Interleavings. Common to have: CS 62 Fall 2016 Kim Bruce & Peter Mawhorter
Sharing is the Key Lecture 25: Parallelism CS 62 Fall 2016 Kim Bruce & Peter Mawhorter Some slides based on those from Dan Grossman, U. of Washington Common to have: Different threads access the same resources
More informationWhy GC is eating all my CPU? Aprof - Java Memory Allocation Profiler Roman Elizarov, Devexperts Joker Conference, St.
Why GC is eating all my CPU? Aprof - Java Memory Allocation Profiler Roman Elizarov, Devexperts Joker Conference, St. Petersburg, 2014 Java Memory Allocation Profiler Why it is needed? When to use it?
More informationDelft-Java Link Translation Buffer
Delft-Java Link Translation Buffer John Glossner 1,2 and Stamatis Vassiliadis 2 1 Lucent / Bell Labs Advanced DSP Architecture and Compiler Research Allentown, Pa glossner@lucent.com 2 Delft University
More informationPause-Less GC for Improving Java Responsiveness. Charlie Gracie IBM Senior Software charliegracie
Pause-Less GC for Improving Java Responsiveness Charlie Gracie IBM Senior Software Developer charlie_gracie@ca.ibm.com @crgracie charliegracie 1 Important Disclaimers THE INFORMATION CONTAINED IN THIS
More informationCMPSCI 187: Programming With Data Structures. Lecture #16: Thinking About Recursion David Mix Barrington 12 October 2012
CMPSCI 187: Programming With Data Structures Lecture #16: Thinking About Recursion David Mix Barrington 12 October 2012 Thinking About Recursion Review of the Grid Class Recursion on Linked Structures
More informationThreads Chate Patanothai
Threads Chate Patanothai Objectives Knowing thread: 3W1H Create separate threads Control the execution of a thread Communicate between threads Protect shared data C. Patanothai Threads 2 What are threads?
More informationIntroduction to Computing II (ITI 1121) Final Examination
Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of Engineering School of Electrical Engineering and Computer Science Introduction
More informationAdvanced programming for Java platform. Introduction
Advanced programming for Java platform Introduction About course Petr Hnětynka hnetynka@d3s.mff.cuni.cz http://d3s.mff.cuni.cz/teaching/vsjava/ continuation of "Java (NPRG013)" basic knowledge of Java
More informationPriming Java for Speed
Priming Java for Speed Getting Fast & Staying Fast Gil Tene, CTO & co-founder, Azul Systems 2013 Azul Systems, Inc. High level agenda Intro Java realities at Load Start A whole bunch of compiler optimization
More informationThe New Java Technology Memory Model
The New Java Technology Memory Model java.sun.com/javaone/sf Jeremy Manson and William Pugh http://www.cs.umd.edu/~pugh 1 Audience Assume you are familiar with basics of Java technology-based threads (
More informationKotlin for Android Developers
Kotlin for Android Developers Learn Kotlin the easy way while developing an Android App Antonio Leiva This book is for sale at http://leanpub.com/kotlin-for-android-developers This version was published
More informationCSE 613: Parallel Programming. Lecture 17 ( Concurrent Data Structures: Queues and Stacks )
CSE 613: Parallel Programming Lecture 17 ( Concurrent Data Structures: Queues and Stacks ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Spring 2012 Desirable Properties of Concurrent
More informationCS350: Data Structures Stacks
Stacks James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Stacks Stacks are a very common data structure that can be used for a variety of data storage
More informationCSE332: Data Abstractions Lecture 19: Mutual Exclusion and Locking
CSE332: Data Abstractions Lecture 19: Mutual Exclusion and Locking James Fogarty Winter 2012 Including slides developed in part by Ruth Anderson, James Fogarty, Dan Grossman Banking Example This code is
More informationStacks and Their Applications
Chapter 5 Stacks and Their Applications We have been discussing general list structures. In practice, we often work with some restricted cases, in which insertions and/or deletions occur only at one or
More informationBlocking Non-blocking Caveat:
Overview of Lecture 5 1 Progress Properties 2 Blocking The Art of Multiprocessor Programming. Maurice Herlihy and Nir Shavit. Morgan Kaufmann, 2008. Deadlock-free: some thread trying to get the lock eventually
More informationDM550 Introduction to Programming part 2. Jan Baumbach.
DM550 Introduction to Programming part 2 Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net COURSE ORGANIZATION 2 Course Elements Lectures: 10 lectures Find schedule and class rooms in online
More informationComputer Science 62. Midterm Examination
Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 Your name (Please print) 1. Suppose you are given a singly-linked list
More informationF. Tip and M. Weintraub CONCURRENCY
F. Tip and M. Weintraub CONCURRENCY SHARED-MEMORY CONCURRENCY threads execute concurrently threads communicate values via shared memory synchronization using locks 2 PITFALLS data races atomicity violations
More informationKotlin for Android developers
ROME - APRIL 13/14 2018 Kotlin for Android developers Victor Kropp, JetBrains @kropp Kotlin on JVM + Android JS In development: Kotlin/Native ios/macos/windows/linux Links Kotlin https://kotlinlang.org
More informationOverview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions
CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to
More informationPrinciples of Software Construction: Concurrency, Part 1
Principles of Software Construction: Concurrency, Part 1 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Midterm review tomorrow 7-9pm, HH B103 Midterm on Thursday HW 5 team signup
More informationKodewerk. Java Performance Services. The War on Latency. Reducing Dead Time Kirk Pepperdine Principle Kodewerk Ltd.
Kodewerk tm Java Performance Services The War on Latency Reducing Dead Time Kirk Pepperdine Principle Kodewerk Ltd. Me Work as a performance tuning freelancer Nominated Sun Java Champion www.kodewerk.com
More informationComputation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007
CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Threads and Synchronization May 8, 2007 Computation Abstractions t1 t1 t4 t2 t1 t2 t5 t3 p1 p2 p3 p4 CPU 1 CPU 2 A computer Processes
More informationMultiThreading. Object Orientated Programming in Java. Benjamin Kenwright
MultiThreading Object Orientated Programming in Java Benjamin Kenwright Outline Review Essential Java Multithreading Examples Today s Practical Review/Discussion Question Does the following code compile?
More informationDeep dive into Coroutines on JVM. Roman Elizarov elizarov at JetBrains
Deep dive into Coroutines on JVM Roman Elizarov elizarov at JetBrains There is no magic Continuation Passing Style (CPS) A toy problem fun postitem(item: Item) { val token = requesttoken() val post = createpost(token,
More informationPrinciples of Software Construction: Concurrency, Part 2
Principles of Software Construction: Concurrency, Part 2 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Homework 5a due now Homework 5 framework goals: Functionally correct Well documented
More informationIntroduction to High Performance Computing and X10
Introduction to High Performance Computing and X10 Special Topic For Comp 621 Vineet Kumar High Performance Computing Supercomputing Grid computers, Multi-cores, clusters massively parallel computing Used
More information