Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Gpars - the coolest bits

400 views

Published on

Slides from my presentation about GPars given at Warsaw Groovy User Group (2014.10.16)

Source code for demo sessions available here:
https://github.com/ArturGajowy/gpars-coolest-bits

Published in: Software
  • Be the first to comment

  • Be the first to like this

Gpars - the coolest bits

  1. 1. The coolest bits
  2. 2. Why bother!?
  3. 3. GPars Groovy Parallel Systems - multiple high-level parallelism abstractions - Java-usable - GAE-usable - part of Groovy SDK - open source (Apache 2 License) - Grooovy documentation
  4. 4. GPars Groovy Parallel Systems Team: Václav Pech, Dierk König, Russel Winder, Alex Tkachman, Paul King, Jon Kerridge, Rafał Sławik and others
  5. 5. One Ring to rule them all... Parallelism approach in GPars (originally?) found in implemented using Parallel collections Scala, Java jsr-166y / JDK5 executors jsr-166y Fork/Join (sugar) Java jsr-166y Actors Erlang, Scala java.util.concurrent Software Transactional Memory Clojure, Scala Multiverse Agents Clojure java.util.concurrent CSP CSP :) Dataflow* or JCSP Dataflow and extensions: Linda, Verilog, Agilent Vee, Pipelines, Kanbanflow Scala, Unreal Engine jsr-166y / JDK5 executors (?) Composable asynchronous functions ? jsr-166y / JDK5 executors
  6. 6. Our focus Parallelism approach in GPars (originally?) found in implemented using Parallel collections Scala, Java jsr-166y / JDK5 executors jsr-166y Fork/Join (sugar) Java jsr-166y Actors Erlang, Scala java.util.concurrent Software Transactional Memory Clojure, Scala Multiverse Agents Clojure java.util.concurrent CSP CSP :) Dataflow* or JCSP Dataflow and extensions: Linda, Verilog, Agilent Vee, jsr-166y / JDK5 executors Pipelines, Kanbanflow Scala, Unreal Engine (?) Composable asynchronous functions ? jsr-166y / JDK5 executors
  7. 7. Demo time! Enabling GPars GDSL in Intellij IDEA
  8. 8. Demo time! Parallel collections - withPool / enhancer - makeConcurrent / makeSequential / asParallel - GParsPool + ParallelEnhancer / GParsExecutorsPool + GParsExecutorsPoolEnhancer - Map-Reduce (Fork / Join pool only)
  9. 9. Things to consider / a warning... In this approach, your iteration body must be: - stateless - side-effect free - constrained to the current element Else - welcome to concurrency hell...
  10. 10. Demo time! Agents - updating immutable / mutable - syntax equivalents for .send - copy method - parallel behaviour - error handling - parallel groups, daemon threads shutting down
  11. 11. Agents - what else is there - listeners - validators validation gotchas - non-closure sends - prefer composition over inheritance - sendAndAwait
  12. 12. Agents - Q A Questions? - what if I want to check a condition before updating state? - how do I 'lock' the state?
  13. 13. Demo time! Composable Asynchronous Functions - @AsyncFun / asyncFun() - async funs return DataflowVariable-s - blocking @AsyncFun-s for convenience - rest of the docs: instantiation variants, pool configuration
  14. 14. Bonus: on parallelism flavours
  15. 15. Choosing an approach Task parallelism Independent Async closures, Futures, whatever... Dependent Random / Unknown Dataflow Functional / Linear Composable asynchronous functions, Dataflow tasks, CSP Hierarchical / Recursive Fork / Join Shared state Agents, STM
  16. 16. Choosing an approach Data parallelism Geometrical / Linear Parallel collections Hierarchical / Recursive Fork / Join Streamed (regular) Pipeline DSL, Dataflow, CSP Event-driven (irregular) Actors
  17. 17. From GPARS User Guide
  18. 18. TL;DR Parallel collections Async functions Dataflow Agents Message passing - CSP - Dataflow - Actors
  19. 19. Also: Bashing actors a little :) Actors are overrated Dierk König
  20. 20. Also: Bashing actors a little :) Why there were no Actors in Clojure* ● complex ● no efficient sharing even for immutable structures ● reduce flexibility ● do not really distribute well from single to many machines * a purposefully exaggerating summary by me
  21. 21. Slides since Morpheus based on ● Václav Pech - GPars How To Guide ● Paul King - Concurrency with GPars ● GPars User Guide - Applicability of concepts ● GPars docs - Concepts compared ● Dierk König - Concurrent programming for you and me ● my personal biases :)
  22. 22. Recap - GPars is quite a lib :) - Be sure to try Dataflows - Actors are overrated ;)
  23. 23. Questions?
  24. 24. Thank you!

×