Share
Embed
Understanding and Overcoming Parallelism Bottlenecks in ForkJoin Applications
Gustavo Pinto
January 14, 2018
Transcript
69 slides
-
Understanding and Overcoming Parallelism Bottlenecks in ForkJoin Applications F. Castor
A. Canino @gustavopinto Y. D. Liu G. Xu -
Modern Java applications run on parallel architectures java.lang.Thread • Widely
used • Low level API • Error prone • Well used • High Level API • User friendly java.util.concurrent.Executors -
Modern Java applications run on parallel architectures java.lang.Thread • Widely
used • Low level API • Error prone • Well used • High Level API • User friendly java.util.concurrent.Executors ForkJoin • Can be more used • Sophisticated API • Sophisticated scheduler -
Modern Java applications run on parallel architectures java.lang.Thread • Widely
used • Low level API • Error prone • Well used • High Level API • User friendly java.util.concurrent.Executors • Can be more used • Sophisticated API • Sophisticated scheduler ForkJoin -
Why ForkJoin? Divider and conquer algorithm @gustavopinto fork() fork() fork()
fork() fork() fork() -
Why ForkJoin? Divider and conquer algorithm @gustavopinto fork() fork() fork()
fork() join() fork() fork() join() -
Why ForkJoin? Divider and conquer algorithm @gustavopinto fork() fork() fork()
fork() join() fork() fork() join() join() join() -
Why ForkJoin? Divider and conquer algorithm @gustavopinto fork() fork() fork()
fork() join() fork() fork() join() join() join() n ForkJoin Task -
Why ForkJoin? Work Stealing 1 2 3 4 7 3
5 1 n n ForkJoin Task ForkJoin Worker 4 9 10 13 2 6 12 11 8 @gustavopinto -
Why ForkJoin? Work Stealing 1 2 3 4 7 3
5 1 n n ForkJoin Task 4 9 10 13 2 6 12 11 8 ForkJoin Worker @gustavopinto -
Why ForkJoin? Work Stealing 1 2 3 4 7 3
1 n n ForkJoin Task 4 9 10 13 2 6 12 11 8 ForkJoin Worker @gustavopinto -
Why ForkJoin? Work Stealing 1 2 3 4 7 3
1 n n ForkJoin Task 4 9 10 13 2 6 12 11 8 2 ForkJoin Worker @gustavopinto -
Why ForkJoin? Work Stealing 1 2 3 4 7 3
1 n n ForkJoin Task 4 9 10 13 6 12 11 8 2 ForkJoin Worker @gustavopinto -
ForkJoin Applications What are the ForkJoin applications? 1. Search for
java.util.concurrent.ForkJoinPool 2. Investigate if ForkJoin is indeed used 3. Filter out class assignments and pet projects 4. Try to build and run the code @gustavopinto Application Programmers -
ForkJoin Applications What are the ForkJoin applications? 1. Search for
java.util.concurrent.ForkJoinPool 2. Investigate if ForkJoin is indeed used 3. Filter out class assignments and pet projects 4. Try to build and run the code ecco ejisto mandelbrot knn jacer conflate cq4j mywiki exhibitor warp lowlatency … 30 projects selected e.g., @gustavopinto Application Programmers 380KLoC ~ -
ForkJoin Applications What about that higher level libs? 1. 330K
lines of code 2. 21k commits 3. 470 source code contributors 4. Written (mostly) in Scala and Java 5. Well-known and well-used @gustavopinto System Programmers -
This paper A depth-oriented study and restructuring of the akka
message passing algorithm @gustavopinto A breadth-oriented study of 30 real-world ForkJoin open- source projects A refactoring tool (the first aimed at improving energy consumption of parallel systems) -
Understanding Parallelism Bottlenecks v0 For each version, we measured execution
time and energy consumption Intel CPU: A 2×8-core (32-cores w/ hyper-threading), running Debian, 2.60GHz, with 64GB of memory, JDK version 1.7 .0 71, build 14. JRapl: Software-based energy measurement @gustavopinto { … -
Overcoming Parallelism Bottlenecks Bottleneck #1: Centralized pooling actor actors process
their own messages there is no side effect @gustavopinto mailbox -
Overcoming Parallelism Bottlenecks Bottleneck #1: Centralized pooling actor actors process
their own messages actors exchange, but do not share the same message there is no side effect @gustavopinto mailbox -
Overcoming Parallelism Bottlenecks Bottleneck #1: Centralized pooling @gustavopinto ( Centralized
) actor actor mailbox tn = -
Overcoming Parallelism Bottlenecks Work Stealing 1 2 3 4 7
3 5 1 n n ForkJoin Task ForkJoin Worker 4 9 10 13 6 12 11 8 @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #1: Centralized pooling @gustavopinto ( Centralized
) actor actor mailbox tn = -
Overcoming Parallelism Bottlenecks Bottleneck #1: Centralized pooling ( Centralized )
@gustavopinto ( DEcentralized ) actor actor actor actor mailbox tn = -
Overcoming Parallelism Bottlenecks Bottleneck #1: Centralized pooling ( Centralized )
@gustavopinto ( DEcentralized ) actor actor actor actor mailbox tn = mailbox .fork() -
Overcoming Parallelism Bottlenecks Bottleneck #1: Centralized pooling ( Centralized )
@gustavopinto ( DEcentralized ) actor actor actor actor mailbox tn = mailbox .fork() tn -
Overcoming Parallelism Bottlenecks Work Stealing 1 2 3 4 7
3 5 1 n n ForkJoin Task ForkJoin Worker 4 9 10 13 6 12 11 8 @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #1: Centralized pooling ( Centralized )
@gustavopinto ( DEcentralized ) actor actor actor actor mailbox tn = mailbox .fork() tn -
Overcoming Parallelism Bottlenecks Bottleneck #2: Copy on Fork a b
c d e f g h t1 = t2 = first half t3 = second half @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #2: Copy on Fork a b
c d e f g h t1 = t1 t2 t3 t2 = first half t3 = second half @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #2: Copy on Fork a b
c d e f g h t1 = t1 t2 t3 t2 = first half t3 = second half make global @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #2: Copy on Fork a b
c d e f g h t1 = t1 t2 t3 t2 = first half t3 = second half 0 1 2 3 4 5 6 7 @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #2: Copy on Fork a b
c d e f g h t1 = t1 t2 t3 t2 = first half t3 = second half 1 2 5 6 Up to 20% of energy savings! @gustavopinto 0 3 4 7 -
Overcoming Parallelism Bottlenecks Bottleneck #3: Copy on Join t1 =
t2 = t3 = t1 + t2 a b c d e f g h @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #3: Copy on Join t1 =
t2 = t3 = t1 + t2 a b c d e f g h t1 t2 t3 @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #3: Copy on Join t1 =
t2 = t3 = t1 + t2 a b c d e f g h t1 t2 t3 0 1 2 3 0 1 2 3 @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #3: Copy on Join t1 =
t2 = t3 = t1 + t2 a b c d e f g h t1 t2 t3 1 2 1 2 Up to 12% of energy savings! @gustavopinto 0 3 0 3 -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask b = forks the subtask @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 a b c d b = forks the subtask @gustavopinto a -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 a b c d tn new b = forks the subtask @gustavopinto a -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 a b c d tn new b = forks the subtask @gustavopinto a -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 a b c d tn tn .fork() new b = forks the subtask @gustavopinto a b -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 a b c d tn tn .fork() new many times b = forks the subtask @gustavopinto a b -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 = aaaabbbb… b = forks the subtask @gustavopinto -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 = aaaabbbb… t1 a b c d tn new b = forks the subtask @gustavopinto a -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 = aaaabbbb… t1 a b c d tn new list.add( ) tn b = forks the subtask @gustavopinto a -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask t1 = aaaabbbb… t1 a b c d tn new list.add( ) tn global b = forks the subtask @gustavopinto a -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask b = forks the subtask t1 = aaaabbbb… t1 a b c d tn new list.add( ) tn global after creating the objects.. for task in list: tn .fork() @gustavopinto a b -
Overcoming Parallelism Bottlenecks Bottleneck #4: Scattered Data t1 = ababababab
… a = memory copies for a subtask b = forks the subtask t1 = aaaabbbb… t1 a b c d tn new list.add( ) tn global after creating the objects.. for task in list: tn .fork() 10% of energy savings 3% less cache misses 5% less context switches @gustavopinto a b -
Overcoming Parallelism Bottlenecks Patching Bottleneck #2: Copy on Fork 7/9
of projects that replied have accepted the PR @gustavopinto -
Understanding and Overcoming Parallelism Bottlenecks in ForkJoin Applications F. Castor
A. Canino @gustavopinto Y. D. Liu G. Xu