Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vaclav Pech on GPars
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Enterprise Java User Group Austria
March 05, 2012
Technology
42
0
Share
Vaclav Pech on GPars
Enterprise Java User Group Austria
March 05, 2012
More Decks by Enterprise Java User Group Austria
See All by Enterprise Java User Group Austria
Gerrit Grunwald on What the CRaC... SUPERFAST JVM STARTUP
ejug
2
180
Spring Framework 5.2 - Core Container Revisited
ejug
0
170
Andreas Caternberg on Jenkins Pipelines
ejug
0
770
Martin Ahrer on Continuous Delivery Infrastructure With Docker
ejug
0
160
Dirk Mahler on Software Analyse mit jQAssistant & Neo4j
ejug
1
300
Christoph Strobl on Spring Data & Hypermedia
ejug
0
150
Stefan Armbruster on Graph Modelling Antipatterns
ejug
1
130
Stefan Armbruster on Introduction into Neo4J
ejug
1
91
Michael Nitschinger on Building a reactive Couchbase driver for the JVM
ejug
0
150
Other Decks in Technology
See All in Technology
Shipping AI Agents — Lessons from Production
vvatanabe
0
300
[Oracle TechNight#99] 生成AI時代のAI/ML入門 ~ AIとオラクルデータベースの関係 (前半)
oracle4engineer
PRO
1
140
需要創出(Chatwork)×供給(BPaaS) フライホイールとMoat 実行能力の最適配置とAI戦略
kubell_hr
0
1.6k
COBOL婆さんの伝説
poropinai1966
0
130
Scovilleモバイルエンジニア募集中.pdf
julienrudin
0
140
Microsoft 365 / Microsoft 365 Copilot : 自分の状態を確認する「ラベル」について
taichinakamura
0
430
AWS Agent Registry の基礎・概要を理解する/aws-agent-registry-intro
ren8k
3
430
「QA=テスト」「シフトレフト=スクラムイベントの参加者の一員」の呪縛を解く。アジャイルな開発を止めないために、10Xで挑んだ「右側のしわ寄せ」解消記 #scrumniigata
nihonbuson
PRO
1
140
Forget technical debt
ufried
0
140
Pure Intonation on Browser: Building a Sequencer with Ruby
nagachika
0
390
20260428_Product Management Summit_tadokoroyoshiro
tadokoro_yoshiro
15
17k
【技術書典20】OpenFOAM(自宅で深める流体解析)流れと熱移動(2)
kamakiri1225
0
350
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
0
900
4 Signs Your Business is Dying
shpigford
187
22k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.6k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
110
Believing is Seeing
oripsolob
1
120
We Have a Design System, Now What?
morganepeng
55
8.1k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.9k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
520
Site-Speed That Sticks
csswizardry
13
1.2k
Deep Space Network (abreviated)
tonyrice
0
130
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
130
Transcript
GPars Promises to keep Václav Pech
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
We're all parallel now Use them or leave them!
None
# of cores
# of cores Today Soon
Dealing with threads sucks! public class Counter { private static
long count = 0; public Counter() { count++; } }
Dealing with threads sucks! public class Counter { private static
long count = 0; public Counter() { synchronized (this) { count++; } } }
Dealing with threads sucks! public class Counter { private static
long count = 0; public Counter() { synchronized (this.getClass()) { count++; } } }
Dealing with threads sucks! public class ClickCounter implements ActionListener {
public ClickCounter(JButton button) { button.addActionListener(this); } public void actionPerformed(final ActionEvent e) { ... } }
images.eachParallel {it.process()} documents.sumParallel() candidates.maxParallel {it.salary}.marry() Parallel Collections
Parallel Collections progLanguages.parallel.filter {it.concurrent} .max {it.javaInteroperability} .map {it.logo} ==
Fork/Join Solve hierarchical problems Divide and conquer
Merge sort, Quick sort Tree traversal File scan / search … [a, b, c, d, e, f, g, h] [a, b, c, d] [e, f, g, h] [a, b] [c, d] [e, f] [g, h]
Thread Pool Tasks Worker threads Queue
Thread Pool Contention!
Fork/Join Thread Pool
Fork/Join Thread Pool Work stealing
Languages are either concurrent or obsolete.
Java 5 Asynchronous calculations
Java 7 Asynchronous calculations Fork/Join
Java 8 Asynchronous calculations Fork/Join Parallel collections
Scala Asynchronous calculations Fork/Join Parallel collections Actors
Clojure Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm
Oz Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow
Google's Go Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm
Dataflow CSP
Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow CSP
Asynchronous calculations Fork/Join Parallel collections Actors Agents, Stm Dataflow CSP
Agenda
Actors Processes with a mail-box Share no data Communicate by
sending messages Use a thread-pool
Stateless Actors (pure Java) class MyActor extends DynamicDispatchActor { Account
account = ... public void onMessage(String msg) { String encripted = encrypt(msg); reply(encripted); } public void onMessage(Integer number) { reply(2 * number); } public void onMessage(Money cash) { System.out.println("Received a donation " + cash); account.deposit(cash); } }
Active Objects @ActiveObject class MyCounter { private int counter =
0 @ActiveMethod def incrementBy(int value) { println "Received an integer: $value" this.counter += value } }
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
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()
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
int hash(String text) {…} Promise<int> hash(Promise<String> | String text)
int hash(String text) {…} Promise<int> hash(Promise<String> | String text) compare(
hash( download() ), hash( loadFile() ) )
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 }
Composing async functions Combine functions as usual Parallelism is detected
automatically
Dataflow Concurrency No race-conditions No live-locks Deterministic
deadlocks Completely deterministic programs BEAUTIFUL code (Jonas Bonér)
Dataflow Variables / Promises main task2 task3 x y z
task1
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
operator(inputs: [headers, bodies, footers], outputs: [articles, summaries]) {header, body, footer
-> def article = buildArticle(header, body, footer) bindOutput(0, article) bindOutput(1, buildSummary(article)) } * + <> Dataflow Operators
Url resolver Url resolver Downloader Groovy scanner Scala scanner Url
resolver Url resolver Reporter Speculator Evaluator Splitter Confirm Cache updates Approvals Dataflow Operators
None
'coz concurrency is Groovy Find more at: http://gpars.codehaus.org http://www.jroller.com/vaclav http://twitter.com/vaclav_pech
GPars