gpars
play

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


  1. GPars Groovy Parallel Systems Václav Pech

  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

  3. We're all parallel now Use them or leave them!

  4. # of cores Tomorrow Today

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

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

  7. Languages are either concurrent or obsolete.

  8. Java 5 Asynchronous calculations

  9. Java 7 Asynchronous calculations Fork/Join

  10. Java 8 Asynchronous calculations Fork/Join Parallel collections

  11. Scala Asynchronous calculations Fork/Join Parallel collections Actors

  12. Clojure Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm

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

  14. Google's Go Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow CSP

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

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

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

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

  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

  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()

  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

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

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

  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 }

  25. Composing async functions Combine functions as usual Parallelism is detected automatically

  26. Dataflow Concurrency  No race-conditions  No live-locks  Deterministic deadlocks Completely deterministic programs BEAUTIFUL code (Jonas Bonér)

  27. Dataflow Variables / Promises main task1 task2 task3 x y z

  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

  29. Dataflow Operators operator(inputs: [headers, bodies, footers], outputs: [articles, summaries]) {header, body, footer -> def article = buildArticle(header, body, footer) bindOutput(0, article) bindOutput(1, buildSummary(article)) } * <> +

  30. Dataflow Operators Url resolver Url resolver Url resolver Url resolver Speculator Downloader Cache updates Evaluator Approvals Splitter Groovy scanner Scala scanner Reporter Confirm

  31. GPars 'coz concurrency is Groovy Find more at: http://gpars.codehaus.org http://www.jroller.com/vaclav http://twitter.com/vaclav_pech

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend