GPars Groovy Parallel Systems Vclav Pech About me ['Passionate - - PowerPoint PPT Presentation

gpars
SMART_READER_LITE
LIVE PREVIEW

GPars Groovy Parallel Systems Vclav Pech About me ['Passionate - - PowerPoint PPT Presentation

GPars Groovy Parallel Systems Vclav Pech About me ['Passionate programmer', 'Concurrency enthusiast', 'GPars lead' , 'Developer/technology evangelist @ JetBrains' ].eachParallel {say it} http://www.jroller.com/vaclav


slide-1
SLIDE 1

GPars

Groovy Parallel Systems Václav Pech

slide-2
SLIDE 2

About me

['Passionate programmer', 'Concurrency enthusiast', 'GPars lead', 'Developer/technology evangelist @ JetBrains' ].eachParallel {say it}

http://www.jroller.com/vaclav http://twitter.com/vaclav_pech

slide-3
SLIDE 3

We're all parallel now

Use them or leave them!

slide-4
SLIDE 4

# of cores

Today Tomorrow

slide-5
SLIDE 5

images.eachParallel {it.process()} documents.sumParallel() candidates.maxParallel {it.salary}.marry()

Parallel Collections

slide-6
SLIDE 6

Parallel Collections

progLanguages.parallel.filter {it.concurrent} .max {it.javaInteroperability} .map {it.logo} ==

slide-7
SLIDE 7

Languages are either concurrent or obsolete.

slide-8
SLIDE 8

Java 5

Asynchronous calculations

slide-9
SLIDE 9

Java 7

Asynchronous calculations Fork/Join

slide-10
SLIDE 10

Java 8

Asynchronous calculations Fork/Join Parallel collections

slide-11
SLIDE 11

Scala

Asynchronous calculations Fork/Join Parallel collections Actors

slide-12
SLIDE 12

Clojure

Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm

slide-13
SLIDE 13

Oz

Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow

slide-14
SLIDE 14

Google's Go

Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow CSP

slide-15
SLIDE 15

Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow CSP

slide-16
SLIDE 16

Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow CSP

Agenda

slide-17
SLIDE 17

Actors

Processes with a mail-box Share no data Communicate by sending messages Use a thread-pool

slide-18
SLIDE 18

Active Objects

@ActiveObject class MyCounter { private int counter = 0 @ActiveMethod def incrementBy(int value) { println "Received an integer: $value" this.counter += value } }

slide-19
SLIDE 19

Composing async functions

int hash1 = hash(download('http://www.gpars.org')) int hash2 = hash(loadFile('/gpars/website/index.html')) boolean result = compare(hash1, hash2) println result

slide-20
SLIDE 20

Composing async functions

@AsyncFun hash = oldHash @AsyncFun compare = oldCompare @AsyncFun download = oldDownload @AsyncFun loadFile = oldLoadFile def hash1 = hash(download('http://www.gpars.org')) def hash2 = hash(loadFile('/gpars/website/index.html')) def result = compare(hash1, hash2) println result.get()

slide-21
SLIDE 21

Composing async functions

@AsyncFun hash = oldHash @AsyncFun(blocking = true) compare = oldCompare @AsyncFun download = oldDownload @AsyncFun loadFile = oldLoadFile def hash1 = hash(download('http://www.gpars.org')) def hash2 = hash(loadFile('/gpars/website/index.html')) boolean result = compare(hash1, hash2) println result

slide-22
SLIDE 22

int hash(String text) {…} Promise<int> hash(Promise<String> | String text)

slide-23
SLIDE 23

int hash(String text) {…} Promise<int> hash(Promise<String> | String text) compare( hash( download() ), hash( loadFile() ) )

slide-24
SLIDE 24

int hash(String text) {…} Promise<int> hash(Promise<String> | String text) { 1.Return a Promise for the result 2.Wait (non-blocking) for the text param 3.Call the original hash() 4.Bind the result }

slide-25
SLIDE 25

Composing async functions

Combine functions as usual Parallelism is detected automatically

slide-26
SLIDE 26

Dataflow Concurrency

 No race-conditions  No live-locks  Deterministic deadlocks

Completely deterministic programs

BEAUTIFUL code

(Jonas Bonér)

slide-27
SLIDE 27

Dataflow Variables / Promises

main task2 task3 x y z task1

slide-28
SLIDE 28

Dataflows

def df = new Dataflows() task { df.z = df.x + df.y } task { df.x = 10 } task { println ”I am task 3” df.y = 5 } assert 15 == df.z

slide-29
SLIDE 29
  • perator(inputs: [headers, bodies, footers],
  • utputs: [articles, summaries])

{header, body, footer -> def article = buildArticle(header, body, footer) bindOutput(0, article) bindOutput(1, buildSummary(article)) }

* + <>

Dataflow Operators

slide-30
SLIDE 30

Url resolver Url resolver Downloader Groovy scanner Scala scanner Url resolver Url resolver Reporter Speculator Evaluator Splitter Confirm

Cache updates Approvals

Dataflow Operators

slide-31
SLIDE 31
slide-32
SLIDE 32

'coz concurrency is Groovy

Find more at:

http://gpars.codehaus.org http://www.jroller.com/vaclav http://twitter.com/vaclav_pech

GPars