SlideShare a Scribd company logo
1 of 23
Fork/Join for Fun and Profit!




               @Sander_Mak
What is the problem anyway?
What is the problem anyway?
What is the problem anyway?
What is the problem anyway?
‣ So let the Compiler figure out the hard stuff!
          if (n < 2) n else fib(n - 1) + fib(n - 2)



                          n < 2




                 n




‣ Or maybe not ...
Fork/Join in pictures

Fork:
Recursively decompose
                                              Result
large task into subtasks
                                              Task 1

Join:                           Task 2                 Task 3
Await results of
recursive tasks            Task 4    Task 5       Task 6    Task 7

and combine
Fork/Join in pseudocode


compute(problem) {
  if (problem.size < threshold)
    directlySolve(problem)
  else {
    do-forked {
       leftResult = compute(left(problem))
       rightResult = compute(right(problem))
    }
    join(leftResult, rightResult)
    return combine(leftResult, rightResult)
  }
}
ForkJoinPool


Introducing:
  java.uCl.concurrent.ForkJoinPool
                                               ForkJoinTask
  java.uCl.concurrent.ForkJoinTask


                                     RecursiveAction   RecursiveTask
ForkJoinPool:
void            execute (ForkJoinTask<?>)
T               invoke (ForkJoinTask<T>)
ForkJoinTask<T> submit (ForkJoinTask<T>)
  
ForkJoinPool


Introducing:
  java.uCl.concurrent.ForkJoinPool   Worker 1



‣    Implements ExecutorService
‣    Autosizing workers              Worker 2
‣    Double‐ended queue
‣    Workstealing algorithm
                                     Worker 3
  
Sorting demo



Mergesort
ForkJoinTasks

‣ 100 < ‘basic computaConal steps’ < 10.000
‣ Acyclic, typically decreasing in size
‣ Join doesn’t block thread!
‣ Do: 
    ‣ OpCmize sequenCal threshold
    ‣ Share, don’t copy input (task locality)
‣ Don’t:
    ‣ Synchronize/lock (but use: Phaser)
    ‣ Do blocking I/O
Work stealing




Worker 1         Worker 2   Worker 3


           ForkJoinPool
Speedups
What about threads?


‣ Heavyweight (try starCng a million)
‣ Implicit dependencies between tasks
   ‣ Manual synchronizaCon
   ‣ Deadlock/livelock/race condiCons
‣ Hard to scale to available parallelism
Pooling/ExecutorService then?


‣ ForkJoinPool implements ExecutorService
‣ Coarse‐grained independent tasks
‣ Recursively decomposed tasks spend most Cme 
  waiCng
   ‣ In normal threadpool: starvaCon
‣ Task‐queue of threadpool‐backed ExecutorService not 
  opCmized for many small tasks
‣ No workstealing
Map/Reduce?




Environment    Single JVM          Cluster

Model          Recursive forking   O^en single map

Scales with    Cores/CPUs          Nodes

Worker         Workstealing        No inter‐node 
interacDon                         communicaCon
Demo


Sony’s been hacked...




            Are we compromised...?
Fork/Join and


‣ ForkJoinPool starts threads
  ‣ Illegal in EJBs
  ‣ Fair game in servlets/CDI beans
‣ Don’t create ForkJoinPool for each request
‣ Idea: WorkManager to create poolthreads
‣ Single pool, async submit(ForkJoinTask)
  ‣ Don’t Ce up request thread: Servlet 3.0
Alternatives outside Java?


‣   Actors
‣   So^ware transacConal memory
‣   Dataflow concurrency
‣   Agents
‣   ... Some of this built on F/J



            Akka                    GPars
Criticism


‣ ImplementaCon too complex (uses Unsafe)
‣ Some assumpCons quesConable
   ‣ 1‐1 mapping workerthread/OS thread
   ‣ Workstealing best opCon?
‣ Scalability 100+ cores?
Future
                                                               GPU?
                                                 Java 8        OpenCL?

                                     Java 7
                                                 Parallel
                 Java 5                          Collections
                                     Fork/Join
Java
1.0 - 1.4        - j.u.concurrent:
                 high-level locks,
                 concurrent coll.
- threads
- synchronized
- volatile
Future




int scanLog(List<String> lines, String query) {
   Pattern p = ...
   return lines.parallel()
               .filter(s => p.matcher(s).matches())
               .count();

}
ForkJoinPool.shutDownNow()


       Questions?




Code @ bit.ly/jfall-forkjoin

More Related Content

What's hot

Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
Ken Coenen
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event Systems
Leonardo Borges
 

What's hot (20)

Streams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to RxStreams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to Rx
 
Reactive Java (GeeCON 2014)
Reactive Java (GeeCON 2014)Reactive Java (GeeCON 2014)
Reactive Java (GeeCON 2014)
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
 
Introduction to Reactive Java
Introduction to Reactive JavaIntroduction to Reactive Java
Introduction to Reactive Java
 
Java Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and TrendsJava Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and Trends
 
Threads and concurrency in Java 1.5
Threads and concurrency in Java 1.5Threads and concurrency in Java 1.5
Threads and concurrency in Java 1.5
 
The Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesThe Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFutures
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
RxJava@DAUG
RxJava@DAUGRxJava@DAUG
RxJava@DAUG
 
From Java 6 to Java 7 reference
From Java 6 to Java 7 referenceFrom Java 6 to Java 7 reference
From Java 6 to Java 7 reference
 
Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Wait for your fortune without Blocking!
Wait for your fortune without Blocking!
 
Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyondReactive Android: RxJava and beyond
Reactive Android: RxJava and beyond
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
The Java memory model made easy
The Java memory model made easyThe Java memory model made easy
The Java memory model made easy
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event Systems
 
Java Concurrency in Practice
Java Concurrency in PracticeJava Concurrency in Practice
Java Concurrency in Practice
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programming
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 

Viewers also liked

Blogstarz Presentation Ter Baru
Blogstarz Presentation Ter BaruBlogstarz Presentation Ter Baru
Blogstarz Presentation Ter Baru
musslizz
 
Knowmads opdracht februari 2011
Knowmads opdracht februari 2011Knowmads opdracht februari 2011
Knowmads opdracht februari 2011
francienvaneersel
 
Embedded linux in_timeandspace_weinberg_2
Embedded linux in_timeandspace_weinberg_2Embedded linux in_timeandspace_weinberg_2
Embedded linux in_timeandspace_weinberg_2
hamed sheykhlu
 
Select Samples of Work
Select Samples of WorkSelect Samples of Work
Select Samples of Work
lizzygreen
 
"Зарядиська"
"Зарядиська""Зарядиська"
"Зарядиська"
unDrei
 
Integrating Social Media With Traditional Media
Integrating Social Media With Traditional MediaIntegrating Social Media With Traditional Media
Integrating Social Media With Traditional Media
parkernow
 

Viewers also liked (20)

Introduction àJava
Introduction àJavaIntroduction àJava
Introduction àJava
 
Don't get stung - an introduction to the OWASP Top 10
Don't get stung - an introduction to the OWASP Top 10Don't get stung - an introduction to the OWASP Top 10
Don't get stung - an introduction to the OWASP Top 10
 
Blogstarz Presentation Ter Baru
Blogstarz Presentation Ter BaruBlogstarz Presentation Ter Baru
Blogstarz Presentation Ter Baru
 
jo s term4 eport
jo s term4 eportjo s term4 eport
jo s term4 eport
 
Knowmads opdracht februari 2011
Knowmads opdracht februari 2011Knowmads opdracht februari 2011
Knowmads opdracht februari 2011
 
Bodene's term 4 eport
Bodene's term 4 eportBodene's term 4 eport
Bodene's term 4 eport
 
Presentacion I Cities 2009
Presentacion I Cities 2009Presentacion I Cities 2009
Presentacion I Cities 2009
 
Embedded linux in_timeandspace_weinberg_2
Embedded linux in_timeandspace_weinberg_2Embedded linux in_timeandspace_weinberg_2
Embedded linux in_timeandspace_weinberg_2
 
Linked In Transaction Offer
Linked In Transaction OfferLinked In Transaction Offer
Linked In Transaction Offer
 
Unenclosable
UnenclosableUnenclosable
Unenclosable
 
VU University Amsterdam - The Social Web 2016 - Lecture 3
VU University Amsterdam - The Social Web 2016 - Lecture 3VU University Amsterdam - The Social Web 2016 - Lecture 3
VU University Amsterdam - The Social Web 2016 - Lecture 3
 
Ideas - Magzine Advert
Ideas - Magzine AdvertIdeas - Magzine Advert
Ideas - Magzine Advert
 
Select Samples of Work
Select Samples of WorkSelect Samples of Work
Select Samples of Work
 
以共融的觀點探討銀髮族節能生活型態之概念設計計畫
以共融的觀點探討銀髮族節能生活型態之概念設計計畫以共融的觀點探討銀髮族節能生活型態之概念設計計畫
以共融的觀點探討銀髮族節能生活型態之概念設計計畫
 
應用微機電感測科技開發未來智慧生活產品
應用微機電感測科技開發未來智慧生活產品應用微機電感測科技開發未來智慧生活產品
應用微機電感測科技開發未來智慧生活產品
 
evaluation
evaluationevaluation
evaluation
 
Symbionomics
SymbionomicsSymbionomics
Symbionomics
 
Unenclosable
UnenclosableUnenclosable
Unenclosable
 
"Зарядиська"
"Зарядиська""Зарядиська"
"Зарядиська"
 
Integrating Social Media With Traditional Media
Integrating Social Media With Traditional MediaIntegrating Social Media With Traditional Media
Integrating Social Media With Traditional Media
 

Similar to Fork/Join for Fun and Profit!

Our challenge for Bulkload reliability improvement
Our challenge for Bulkload reliability  improvementOur challenge for Bulkload reliability  improvement
Our challenge for Bulkload reliability improvement
Satoshi Akama
 
Java if and else
Java if and elseJava if and else
Java if and else
pratik8897
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
Sanjeev Tripathi
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
sanjeeviniindia1186
 
Ten Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project ExperiencesTen Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project Experiences
Henrik Olsson
 

Similar to Fork/Join for Fun and Profit! (20)

Concurrency with side-effects – cats way
Concurrency with side-effects – cats wayConcurrency with side-effects – cats way
Concurrency with side-effects – cats way
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
NYAN Conference: Debugging asynchronous scenarios in .net
NYAN Conference: Debugging asynchronous scenarios in .netNYAN Conference: Debugging asynchronous scenarios in .net
NYAN Conference: Debugging asynchronous scenarios in .net
 
Our challenge for Bulkload reliability improvement
Our challenge for Bulkload reliability  improvementOur challenge for Bulkload reliability  improvement
Our challenge for Bulkload reliability improvement
 
Clojure 1.1 And Beyond
Clojure 1.1 And BeyondClojure 1.1 And Beyond
Clojure 1.1 And Beyond
 
Java if and else
Java if and elseJava if and else
Java if and else
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
Asynchronous development in JavaScript
Asynchronous development  in JavaScriptAsynchronous development  in JavaScript
Asynchronous development in JavaScript
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018
 
Kotlin Coroutines and Rx
Kotlin Coroutines and RxKotlin Coroutines and Rx
Kotlin Coroutines and Rx
 
Async and parallel patterns and application design - TechDays2013 NL
Async and parallel patterns and application design - TechDays2013 NLAsync and parallel patterns and application design - TechDays2013 NL
Async and parallel patterns and application design - TechDays2013 NL
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6
 
Embracing Events
Embracing EventsEmbracing Events
Embracing Events
 
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
4Developers 2015: Programowanie synchroniczne i asynchroniczne - dwa światy k...
 
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
JDD2015: Frege - Introducing purely functional programming on the JVM - Dierk...
 
Ndp Slides
Ndp SlidesNdp Slides
Ndp Slides
 
Ten Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project ExperiencesTen Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project Experiences
 
Functional programming
Functional programmingFunctional programming
Functional programming
 

More from Sander Mak (@Sander_Mak)

Modules or microservices?
Modules or microservices?Modules or microservices?
Modules or microservices?
Sander Mak (@Sander_Mak)
 

More from Sander Mak (@Sander_Mak) (20)

Scalable Application Development @ Picnic
Scalable Application Development @ PicnicScalable Application Development @ Picnic
Scalable Application Development @ Picnic
 
Coding Your Way to Java 13
Coding Your Way to Java 13Coding Your Way to Java 13
Coding Your Way to Java 13
 
Coding Your Way to Java 12
Coding Your Way to Java 12Coding Your Way to Java 12
Coding Your Way to Java 12
 
Java Modularity: the Year After
Java Modularity: the Year AfterJava Modularity: the Year After
Java Modularity: the Year After
 
Desiging for Modularity with Java 9
Desiging for Modularity with Java 9Desiging for Modularity with Java 9
Desiging for Modularity with Java 9
 
Modules or microservices?
Modules or microservices?Modules or microservices?
Modules or microservices?
 
Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
 
Java 9 Modularity in Action
Java 9 Modularity in ActionJava 9 Modularity in Action
Java 9 Modularity in Action
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
 
Provisioning the IoT
Provisioning the IoTProvisioning the IoT
Provisioning the IoT
 
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 
The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)
 
Modular JavaScript
Modular JavaScriptModular JavaScript
Modular JavaScript
 
Modularity in the Cloud
Modularity in the CloudModularity in the Cloud
Modularity in the Cloud
 
Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?
 
Scala & Lift (JEEConf 2012)
Scala & Lift (JEEConf 2012)Scala & Lift (JEEConf 2012)
Scala & Lift (JEEConf 2012)
 
Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)
 
Akka (BeJUG)
Akka (BeJUG)Akka (BeJUG)
Akka (BeJUG)
 
Kscope11 recap
Kscope11 recapKscope11 recap
Kscope11 recap
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 

Recently uploaded (20)

Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 

Fork/Join for Fun and Profit!

Editor's Notes

  1. Sander Mak, Info Support\nGaan het hebben over Doug Lea&amp;#x2019;s fork/join (al sinds 1998 in the works), nu onderdeel van Java7\nFun &amp; Profit: profit vanwege snellere apps, fun hangt van je interesses af :)\n
  2. No choice but to churn on each task sequentially\nPentium 5, 3.4Ghz -&gt; hitting physical limits! (approach: speed, smarter instructions onchip)\nThreading alleviates IO contention, not CPU contention\n
  3. No choice but to churn on each task sequentially\nPentium 5, 3.4Ghz -&gt; hitting physical limits! (approach: speed, smarter instructions onchip)\nThreading alleviates IO contention, not CPU contention\n
  4. More cores, lower speed. Do nothing -&gt; your app could be slower! Embrace parallelism.\nIn webapps we get a lot of request-oriented parallelism for free.\nWhat about other applications/algorithms?\n
  5. CPU architectures changed all the time without having to change Java code... why is this different? -&gt; Implicit data-dependencies in code (also, shared memory/state problems)\n
  6. Builds a tree with explicit dependencies between tasks!\nDivide-and-conquer algorithms\nHier: 6 fork acties, 6 join acties\n
  7. Threshold is key: overhead vs. effective work per unit\nApplicable to for example:search, sort, aggregating data\n
  8. ForkJoinTask is a future\n
  9. - getAvailableProcessors on System.runtime\n- possible to set own size (e.g. restrict to 4 of n cores)\n
  10. \n
  11. \n
  12. - forked tasks pushed on top local deque\n- idle worker steals from bottom deque of other worker -&gt; prevent contention on deque, and largest tasks get stolen!\n- no work stolen? eventually yield workerthread. Typ. 0-2% stolen\n- Workstealing == loadbalancing without central coord!\n
  13. Fibonacci in het begin bekeken. Allemaal reken-intensief.\nSprekend voorbeeld: password hashes tegen rainbow table aanhouden.\n
  14. Still threads are better when doing blocking I/O networking etc.\n
  15. \n
  16. F/J: recursively apply same task, M/R: apply different map/reduce steps, not necessarily recursive (but could happen)\n
  17. \n
  18. Websphere staat bv ook geen threadcreatie in servlet toe\nEvt. JCA adapter noemen\n
  19. \n
  20. \n
  21. \n
  22. needs lambdas!\nbut already available in jsr166y with anonymous inner classes\n
  23. \n