SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Stefan Marr, Hanspeter Mössenböck
AGERE! Workshop
October 26, 2015
Optimizing
Communicating Event-Loop
Languages with Truffle
Research funded by
NS
Initial Goals
• Safety
– Guaranteed Isolation
– No Low-Level Data Races
• Deadlock Freedom
• Performance Competitive with Java
2
NS: A Platform For Concurrency Research
Communicating Event Loops
3
E Programming Language
à la
Communicating Event Loops
4
Actor A Actor B
Actor Principle
Communicating Event Loops
5
Actor A Actor B
But, Actor Not First-Class
Communicating Event Loops
6
Actor A Actor B
Actors Contain Objects
Communicating Event Loops
7
Actor A Actor B
Objects Can Have Far-References
public class PingPong new = Benchmark <: Value (
class Ping new: cnt with: pongAct = (
private pingsLeft ::= cnt. (* mutable slot *)
private pongAct = pongAct. (* immutable slot *)
)(
8
Newspeak
A Class-based Language
Dynamically Typed
No Global/Static State
public class PingPong new = Benchmark <: Value (
class Ping new: cnt with: pongAct = (
private pingsLeft ::= cnt. (* mutable slot *)
private pongAct = pongAct. (* immutable slot *)
)(
9
Newspeak
public ping = (
pongAct <-: ping: self.
pingsLeft := pingsLeft - 1.
)
Communicating Event-Loop Actors
public class PingPong new = Benchmark <: Value (
class Ping new: cnt with: pongAct = (
private pingsLeft ::= cnt. (* mutable slot *)
private pongAct = pongAct. (* immutable slot *)
)(
10
Newspeak
Newspeak Programming Language Draft
Specification Version 0.095
http://bracha.org/newspeak-spec.pdf
With Spec:
public ping = (
pongAct <-: ping: self.
pingsLeft := pingsLeft - 1.
)
: Built on Truffle
11
cnt
1
+
cnt:
=
if
cnt:
=
0
cnt
1
+
cnt:
=if cnt:
=
0
NS
Truffle’s Self-Optimization Approach:
[1] Würthinger, T.; Wöß, A.; Stadler, L.; Duboscq, G.; Simon, D. & Wimmer, C. (2012),
Self-Optimizing AST Interpreters, Proceedings of the 8th Dynamic Languages Symposium.
JIT Compiled
Native Code
Self-Optimized AST
: A Fast Newspeak
12
NS
SOMNS versus Java (Graal Compiler)
On average 1.65x slower (min. −3%, max. 2.6x)
0.0
0.5
1.0
1.5
2.0
2.5
3.0
Bounce
BubbleSort
DeltaBlue
Fannkuch
Json
Mandelbrot
NBody
PageRank
Permute
Queens
QuickSort
Richards
Sieve
Storage
Runtimefactornormalized
toJava
RuntimeFactor
NormalizedtoJava
Lower
Is
Better
vs. JVM Actor Libraries
13
NS
Chameneos
ConcurrentSorted
LinkedList
Counting ForkJoinThroughput PingPong RadixSort ThreadRing Geo Mean
0
1
2
3
4
5
6
7
8
RuntimefactoroverScalaz
lowerisbetter
Akka Jetlang SOMns Scalaz
RuntimeFactor
NormalizedtoScalaz
Lower
Is
Better
Savina Benchmarks
[2] Imam, S. M. & Sarkar, V. (2014), Savina - An Actor Benchmark
Suite: Enabling Empirical Evaluation of Actor Libraries, Proceedings of
the 4th AGERE! Workshop, ACM.
TWO OPTIMIZATIONS
Enforcing Isolation
Asynchronous Sends
14
Enforcing Isolation
15
Enforcing Isolation
16
if (isMutableObject(arg[i])) {
return farReference(arg[i]);
} else if (isValueObject(arg[i]) {
return arg[i];
} else if (isFarReference(arg[i]) && toCurrentActor(arg[i])) {
...
} else if (isFarReference...
} else if (isPromise(arg[i])...
...
public traverse: t col: start to: end = (
(* ... *)
)
worker <-: traverse: table col: 1 to: 10
Optimistic AST Specialization
17
async send
WrapArg WrapArg WrapArgWrapArg
ReadVar
worker
ReadVar
table
worker <-: traverse: table col: 1 to: 10
Literal
1
Literal
10
Optimistic AST Specialization
18
async send
WrapArg WrapArg WrapArg
Unwrap
FarRef
ReadVar
worker
ReadVar
table
worker <-: traverse: table col: 1 to: 10
Literal
1
Literal
10
Optimistic AST Specialization
19
async send
IsValue WrapArg WrapArg
Unwrap
FarRef
ReadVar
worker
ReadVar
table
worker <-: traverse: table col: 1 to: 10
Literal
1
Literal
10
Optimistic AST Specialization
20
async send
IsValue
Unwrap
FarRef
ReadVar
worker
ReadVar
table
worker <-: traverse: table col: 1 to: 10
Literal
1
Literal
10
Impact on Microbenchmarks
21
Speedup Factor over Unoptimized Version
public class With10Args new = Benchmark (
private aValue = Value new.
private obj ::= Object new.
public benchmark = (
self <-: a1: aValue a2: Object new a3: obj
a4: Benchmark a5: aValue
a6: 0 a7: 7 a8: 8 a9: #eee a0: '33'.
) )
with 10
arguments
1.0 1.5 2.0 2.5 3.0
Benchmark
Method Lookup for Asynchronous Sends
22
A1
Event-Loop: Single Point of Reception
B
A2
C
do
get
set
do
a1 <-: do
b <-: get
a2 <-: set
c <-: do
Megamorphic Method Invocations
while (true) {
msg = mailbox.receive()
mthd = msg.obj.getClass().
lookup(msg.selector())
mthd.invoke(obj, msg.args)
}
Optimization: Send-site Caching
23
a1 <-: do
actor(a1) <-: fun(o) {
o.do()
}
Code Transformation
Introduces Inline Cache
With Send-site Caching
24
A1
B
A2
C
do
get
set
do
a1 <-: do
b <-: get
a2 <-: set
c <-: do
while (true) {
msg = mailbox.receive()
msg.fun.
invoke(obj, msg.args)
}fun1(.) {…}
fun2(.) {…}
fun3(.) {…}
fun4(.) {…}
Impact on Microbenchmarks
25
Speedup Factor over Unoptimized Version
public count = (
cnt := cnt + 1.
cnt = iterations
ifTrue: [ completionPP resolve: cnt ]
ifFalse: [ self <-: count ]
)
lookup in cls
lookup in
5th supercls
1.0 1.5 2.0 2.5 3.0
Benchmark
Impact on Microbenchmarks
26
Speedup Factor over Unoptimized Version
public calc: a and: b = (
| r |
r := a * b + b + b – a.
r := r - (a * a * b).
^ r
)
lookup in cls
lookup in
5th supercls
with
int or double
1.0 1.5 2.0 3.0 10.0 50.0 100.0
Benchmark
lookup in cls
lookup in
5th supercls
with
int or double
1.0 1.5 2.0 3.0 10.0 50.0 100.0
Benchmark
public benchmark = (
1 to: numIter do: [:i |
self <-: calc: 2 and: 4.
self <-: calc: 1.2 and: 3.3.
].
)
: Fast And Scalable
• Platform for Concurrency Research
• Initial optimizations
– Send-site Caching + Isolation 27
NS
Chameneos
ConcurrentSorted
LinkedList
Counting ForkJoinThroughput PingPong RadixSort ThreadRing Geo Mean
0
1
2
3
4
5
6
7
8
RuntimefactoroverScalaz
lowerisbetter
Akka Jetlang SOMns ScalazLower
Is
Better
RuntimeFactor
NormalizedtoScalaz

Weitere ähnliche Inhalte

Was ist angesagt?

[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming
Tobias Lindaaker
 
Grand Central Dispatch - iOS Conf SG 2015
Grand Central Dispatch - iOS Conf SG 2015Grand Central Dispatch - iOS Conf SG 2015
Grand Central Dispatch - iOS Conf SG 2015
Ben Asher
 

Was ist angesagt? (20)

C++ Coroutines
C++ CoroutinesC++ Coroutines
C++ Coroutines
 
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
 
Functional Programming and Composing Actors
Functional Programming and Composing ActorsFunctional Programming and Composing Actors
Functional Programming and Composing Actors
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPU
 
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
Gor Nishanov,  C++ Coroutines – a negative overhead abstractionGor Nishanov,  C++ Coroutines – a negative overhead abstraction
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
 
Exploiting Concurrency with Dynamic Languages
Exploiting Concurrency with Dynamic LanguagesExploiting Concurrency with Dynamic Languages
Exploiting Concurrency with Dynamic Languages
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014
 
Using R in remote computer clusters
Using R in remote computer clustersUsing R in remote computer clusters
Using R in remote computer clusters
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming
 
Loom and concurrency latest
Loom and concurrency latestLoom and concurrency latest
Loom and concurrency latest
 
Grand Central Dispatch - iOS Conf SG 2015
Grand Central Dispatch - iOS Conf SG 2015Grand Central Dispatch - iOS Conf SG 2015
Grand Central Dispatch - iOS Conf SG 2015
 
GCD and OperationQueue.
GCD and OperationQueue.GCD and OperationQueue.
GCD and OperationQueue.
 
Collections forceawakens
Collections forceawakensCollections forceawakens
Collections forceawakens
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемые
 
Address/Thread/Memory Sanitizer
Address/Thread/Memory SanitizerAddress/Thread/Memory Sanitizer
Address/Thread/Memory Sanitizer
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and Simple
 

Ähnlich wie Optimizing Communicating Event-Loop Languages with Truffle

Direct Code Execution - LinuxCon Japan 2014
Direct Code Execution - LinuxCon Japan 2014Direct Code Execution - LinuxCon Japan 2014
Direct Code Execution - LinuxCon Japan 2014
Hajime Tazaki
 
IA3_presentation.pptx
IA3_presentation.pptxIA3_presentation.pptx
IA3_presentation.pptx
KtonNguyn2
 

Ähnlich wie Optimizing Communicating Event-Loop Languages with Truffle (20)

Inferno Scalable Deep Learning on Spark
Inferno Scalable Deep Learning on SparkInferno Scalable Deep Learning on Spark
Inferno Scalable Deep Learning on Spark
 
Flink Forward SF 2017: Stefan Richter - Improvements for large state and reco...
Flink Forward SF 2017: Stefan Richter - Improvements for large state and reco...Flink Forward SF 2017: Stefan Richter - Improvements for large state and reco...
Flink Forward SF 2017: Stefan Richter - Improvements for large state and reco...
 
Hierarchical free monads and software design in fp
Hierarchical free monads and software design in fpHierarchical free monads and software design in fp
Hierarchical free monads and software design in fp
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
Javantura v4 - Java and lambdas and streams - are they better than for loops ...Javantura v4 - Java and lambdas and streams - are they better than for loops ...
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
 
Golang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war storyGolang Performance : microbenchmarks, profilers, and a war story
Golang Performance : microbenchmarks, profilers, and a war story
 
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDB
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDBBuilding a Scalable Distributed Stats Infrastructure with Storm and KairosDB
Building a Scalable Distributed Stats Infrastructure with Storm and KairosDB
 
So you think you can stream.pptx
So you think you can stream.pptxSo you think you can stream.pptx
So you think you can stream.pptx
 
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp KrennJavantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
 
Streams
StreamsStreams
Streams
 
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
 
Introduction to the Kotlin language
Introduction to the Kotlin languageIntroduction to the Kotlin language
Introduction to the Kotlin language
 
Direct Code Execution - LinuxCon Japan 2014
Direct Code Execution - LinuxCon Japan 2014Direct Code Execution - LinuxCon Japan 2014
Direct Code Execution - LinuxCon Japan 2014
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
 
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
 
Automatic and Interpretable Machine Learning with H2O and LIME
Automatic and Interpretable Machine Learning with H2O and LIMEAutomatic and Interpretable Machine Learning with H2O and LIME
Automatic and Interpretable Machine Learning with H2O and LIME
 
L Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformaticsL Fu - Dao: a novel programming language for bioinformatics
L Fu - Dao: a novel programming language for bioinformatics
 
IA3_presentation.pptx
IA3_presentation.pptxIA3_presentation.pptx
IA3_presentation.pptx
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
 
Spark Streaming with Cassandra
Spark Streaming with CassandraSpark Streaming with Cassandra
Spark Streaming with Cassandra
 

Mehr von Stefan Marr

Which Problems Does a Multi-Language Virtual Machine Need to Solve in the Mul...
Which Problems Does a Multi-Language Virtual Machine Need to Solve in the Mul...Which Problems Does a Multi-Language Virtual Machine Need to Solve in the Mul...
Which Problems Does a Multi-Language Virtual Machine Need to Solve in the Mul...
Stefan Marr
 
Sly and the RoarVM: Exploring the Manycore Future of Programming
Sly and the RoarVM: Exploring the Manycore Future of ProgrammingSly and the RoarVM: Exploring the Manycore Future of Programming
Sly and the RoarVM: Exploring the Manycore Future of Programming
Stefan Marr
 
Metaprogrammierung und Reflection
Metaprogrammierung und ReflectionMetaprogrammierung und Reflection
Metaprogrammierung und Reflection
Stefan Marr
 
Traits: A New Language Feature for PHP?
Traits: A New Language Feature for PHP?Traits: A New Language Feature for PHP?
Traits: A New Language Feature for PHP?
Stefan Marr
 

Mehr von Stefan Marr (17)

Metaprogramming, Metaobject Protocols, Gradual Type Checks: Optimizing the "U...
Metaprogramming, Metaobject Protocols, Gradual Type Checks: Optimizing the "U...Metaprogramming, Metaobject Protocols, Gradual Type Checks: Optimizing the "U...
Metaprogramming, Metaobject Protocols, Gradual Type Checks: Optimizing the "U...
 
Cloud PARTE: Elastic Complex Event Processing based on Mobile Actors
Cloud PARTE: Elastic Complex Event Processing based on Mobile ActorsCloud PARTE: Elastic Complex Event Processing based on Mobile Actors
Cloud PARTE: Elastic Complex Event Processing based on Mobile Actors
 
Supporting Concurrency Abstractions in High-level Language Virtual Machines
Supporting Concurrency Abstractions in High-level Language Virtual MachinesSupporting Concurrency Abstractions in High-level Language Virtual Machines
Supporting Concurrency Abstractions in High-level Language Virtual Machines
 
Identifying A Unifying Mechanism for the Implementation of Concurrency Abstra...
Identifying A Unifying Mechanism for the Implementation of Concurrency Abstra...Identifying A Unifying Mechanism for the Implementation of Concurrency Abstra...
Identifying A Unifying Mechanism for the Implementation of Concurrency Abstra...
 
Sly and the RoarVM: Parallel Programming with Smalltalk
Sly and the RoarVM: Parallel Programming with SmalltalkSly and the RoarVM: Parallel Programming with Smalltalk
Sly and the RoarVM: Parallel Programming with Smalltalk
 
Which Problems Does a Multi-Language Virtual Machine Need to Solve in the Mul...
Which Problems Does a Multi-Language Virtual Machine Need to Solve in the Mul...Which Problems Does a Multi-Language Virtual Machine Need to Solve in the Mul...
Which Problems Does a Multi-Language Virtual Machine Need to Solve in the Mul...
 
Sly and the RoarVM: Exploring the Manycore Future of Programming
Sly and the RoarVM: Exploring the Manycore Future of ProgrammingSly and the RoarVM: Exploring the Manycore Future of Programming
Sly and the RoarVM: Exploring the Manycore Future of Programming
 
PHP.next: Traits
PHP.next: TraitsPHP.next: Traits
PHP.next: Traits
 
The Price of the Free Lunch: Programming in the Multicore Era
The Price of the Free Lunch: Programming in the Multicore EraThe Price of the Free Lunch: Programming in the Multicore Era
The Price of the Free Lunch: Programming in the Multicore Era
 
Locality and Encapsulation: A Foundation for Concurrency Support in Multi-Lan...
Locality and Encapsulation: A Foundation for Concurrency Support in Multi-Lan...Locality and Encapsulation: A Foundation for Concurrency Support in Multi-Lan...
Locality and Encapsulation: A Foundation for Concurrency Support in Multi-Lan...
 
Insertion Tree Phasers: Efficient and Scalable Barrier Synchronization for Fi...
Insertion Tree Phasers: Efficient and Scalable Barrier Synchronization for Fi...Insertion Tree Phasers: Efficient and Scalable Barrier Synchronization for Fi...
Insertion Tree Phasers: Efficient and Scalable Barrier Synchronization for Fi...
 
Encapsulation and Locality: A Foundation for Concurrency Support in Multi-Lan...
Encapsulation and Locality: A Foundation for Concurrency Support in Multi-Lan...Encapsulation and Locality: A Foundation for Concurrency Support in Multi-Lan...
Encapsulation and Locality: A Foundation for Concurrency Support in Multi-Lan...
 
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...
Intermediate Language Design of High-level Language VMs: Towards Comprehensiv...
 
Virtual Machine Support for Many-Core Architectures: Decoupling Abstract from...
Virtual Machine Support for Many-Core Architectures: Decoupling Abstract from...Virtual Machine Support for Many-Core Architectures: Decoupling Abstract from...
Virtual Machine Support for Many-Core Architectures: Decoupling Abstract from...
 
VMADL: An Architecture Definition Language for Variability and Composition ...
VMADL: An Architecture Definition Language  for Variability and Composition  ...VMADL: An Architecture Definition Language  for Variability and Composition  ...
VMADL: An Architecture Definition Language for Variability and Composition ...
 
Metaprogrammierung und Reflection
Metaprogrammierung und ReflectionMetaprogrammierung und Reflection
Metaprogrammierung und Reflection
 
Traits: A New Language Feature for PHP?
Traits: A New Language Feature for PHP?Traits: A New Language Feature for PHP?
Traits: A New Language Feature for PHP?
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

Optimizing Communicating Event-Loop Languages with Truffle

  • 1. Stefan Marr, Hanspeter Mössenböck AGERE! Workshop October 26, 2015 Optimizing Communicating Event-Loop Languages with Truffle Research funded by NS
  • 2. Initial Goals • Safety – Guaranteed Isolation – No Low-Level Data Races • Deadlock Freedom • Performance Competitive with Java 2 NS: A Platform For Concurrency Research
  • 3. Communicating Event Loops 3 E Programming Language à la
  • 4. Communicating Event Loops 4 Actor A Actor B Actor Principle
  • 5. Communicating Event Loops 5 Actor A Actor B But, Actor Not First-Class
  • 6. Communicating Event Loops 6 Actor A Actor B Actors Contain Objects
  • 7. Communicating Event Loops 7 Actor A Actor B Objects Can Have Far-References
  • 8. public class PingPong new = Benchmark <: Value ( class Ping new: cnt with: pongAct = ( private pingsLeft ::= cnt. (* mutable slot *) private pongAct = pongAct. (* immutable slot *) )( 8 Newspeak A Class-based Language Dynamically Typed No Global/Static State
  • 9. public class PingPong new = Benchmark <: Value ( class Ping new: cnt with: pongAct = ( private pingsLeft ::= cnt. (* mutable slot *) private pongAct = pongAct. (* immutable slot *) )( 9 Newspeak public ping = ( pongAct <-: ping: self. pingsLeft := pingsLeft - 1. ) Communicating Event-Loop Actors
  • 10. public class PingPong new = Benchmark <: Value ( class Ping new: cnt with: pongAct = ( private pingsLeft ::= cnt. (* mutable slot *) private pongAct = pongAct. (* immutable slot *) )( 10 Newspeak Newspeak Programming Language Draft Specification Version 0.095 http://bracha.org/newspeak-spec.pdf With Spec: public ping = ( pongAct <-: ping: self. pingsLeft := pingsLeft - 1. )
  • 11. : Built on Truffle 11 cnt 1 + cnt: = if cnt: = 0 cnt 1 + cnt: =if cnt: = 0 NS Truffle’s Self-Optimization Approach: [1] Würthinger, T.; Wöß, A.; Stadler, L.; Duboscq, G.; Simon, D. & Wimmer, C. (2012), Self-Optimizing AST Interpreters, Proceedings of the 8th Dynamic Languages Symposium. JIT Compiled Native Code Self-Optimized AST
  • 12. : A Fast Newspeak 12 NS SOMNS versus Java (Graal Compiler) On average 1.65x slower (min. −3%, max. 2.6x) 0.0 0.5 1.0 1.5 2.0 2.5 3.0 Bounce BubbleSort DeltaBlue Fannkuch Json Mandelbrot NBody PageRank Permute Queens QuickSort Richards Sieve Storage Runtimefactornormalized toJava RuntimeFactor NormalizedtoJava Lower Is Better
  • 13. vs. JVM Actor Libraries 13 NS Chameneos ConcurrentSorted LinkedList Counting ForkJoinThroughput PingPong RadixSort ThreadRing Geo Mean 0 1 2 3 4 5 6 7 8 RuntimefactoroverScalaz lowerisbetter Akka Jetlang SOMns Scalaz RuntimeFactor NormalizedtoScalaz Lower Is Better Savina Benchmarks [2] Imam, S. M. & Sarkar, V. (2014), Savina - An Actor Benchmark Suite: Enabling Empirical Evaluation of Actor Libraries, Proceedings of the 4th AGERE! Workshop, ACM.
  • 16. Enforcing Isolation 16 if (isMutableObject(arg[i])) { return farReference(arg[i]); } else if (isValueObject(arg[i]) { return arg[i]; } else if (isFarReference(arg[i]) && toCurrentActor(arg[i])) { ... } else if (isFarReference... } else if (isPromise(arg[i])... ... public traverse: t col: start to: end = ( (* ... *) ) worker <-: traverse: table col: 1 to: 10
  • 17. Optimistic AST Specialization 17 async send WrapArg WrapArg WrapArgWrapArg ReadVar worker ReadVar table worker <-: traverse: table col: 1 to: 10 Literal 1 Literal 10
  • 18. Optimistic AST Specialization 18 async send WrapArg WrapArg WrapArg Unwrap FarRef ReadVar worker ReadVar table worker <-: traverse: table col: 1 to: 10 Literal 1 Literal 10
  • 19. Optimistic AST Specialization 19 async send IsValue WrapArg WrapArg Unwrap FarRef ReadVar worker ReadVar table worker <-: traverse: table col: 1 to: 10 Literal 1 Literal 10
  • 20. Optimistic AST Specialization 20 async send IsValue Unwrap FarRef ReadVar worker ReadVar table worker <-: traverse: table col: 1 to: 10 Literal 1 Literal 10
  • 21. Impact on Microbenchmarks 21 Speedup Factor over Unoptimized Version public class With10Args new = Benchmark ( private aValue = Value new. private obj ::= Object new. public benchmark = ( self <-: a1: aValue a2: Object new a3: obj a4: Benchmark a5: aValue a6: 0 a7: 7 a8: 8 a9: #eee a0: '33'. ) ) with 10 arguments 1.0 1.5 2.0 2.5 3.0 Benchmark
  • 22. Method Lookup for Asynchronous Sends 22 A1 Event-Loop: Single Point of Reception B A2 C do get set do a1 <-: do b <-: get a2 <-: set c <-: do Megamorphic Method Invocations while (true) { msg = mailbox.receive() mthd = msg.obj.getClass(). lookup(msg.selector()) mthd.invoke(obj, msg.args) }
  • 23. Optimization: Send-site Caching 23 a1 <-: do actor(a1) <-: fun(o) { o.do() } Code Transformation Introduces Inline Cache
  • 24. With Send-site Caching 24 A1 B A2 C do get set do a1 <-: do b <-: get a2 <-: set c <-: do while (true) { msg = mailbox.receive() msg.fun. invoke(obj, msg.args) }fun1(.) {…} fun2(.) {…} fun3(.) {…} fun4(.) {…}
  • 25. Impact on Microbenchmarks 25 Speedup Factor over Unoptimized Version public count = ( cnt := cnt + 1. cnt = iterations ifTrue: [ completionPP resolve: cnt ] ifFalse: [ self <-: count ] ) lookup in cls lookup in 5th supercls 1.0 1.5 2.0 2.5 3.0 Benchmark
  • 26. Impact on Microbenchmarks 26 Speedup Factor over Unoptimized Version public calc: a and: b = ( | r | r := a * b + b + b – a. r := r - (a * a * b). ^ r ) lookup in cls lookup in 5th supercls with int or double 1.0 1.5 2.0 3.0 10.0 50.0 100.0 Benchmark lookup in cls lookup in 5th supercls with int or double 1.0 1.5 2.0 3.0 10.0 50.0 100.0 Benchmark public benchmark = ( 1 to: numIter do: [:i | self <-: calc: 2 and: 4. self <-: calc: 1.2 and: 3.3. ]. )
  • 27. : Fast And Scalable • Platform for Concurrency Research • Initial optimizations – Send-site Caching + Isolation 27 NS Chameneos ConcurrentSorted LinkedList Counting ForkJoinThroughput PingPong RadixSort ThreadRing Geo Mean 0 1 2 3 4 5 6 7 8 RuntimefactoroverScalaz lowerisbetter Akka Jetlang SOMns ScalazLower Is Better RuntimeFactor NormalizedtoScalaz

Hinweis der Redaktion

  1. Talk: 18min + 5min questions
  2. Can safe actor languages be efficient & usable enough for complex concurrent applications?