SlideShare a Scribd company logo
Sista: Improving 
Cog’s JIT 
performance 
Clément Béra
Main people involved in Sista 
• Eliot Miranda 
• Over 30 years experience in Smalltalk VM 
• Clément Béra 
• 2 years engineer in the Pharo team 
• Phd student starting from october
Cog ? 
• Smalltalk virtual machine 
• Runs Pharo, Squeak, Newspeak, ...
Plan 
• Efficient VM architecture (Java, C#, ...) 
• Sista goals 
• Example: optimizing a method 
• Our approach 
• Status
Virtual machine 
High level code (Java, Smalltalk ...) 
Runtime environment (JRE, JDK, Object engine...) 
CPU: intel, ARM ... - OS: Windows, Android, Linux ..
Basic Virtual machine 
High level code (Java, Smalltalk ...) 
Compiler 
Bytecode VM 
Bytecode 
Interpreter 
Memory Manager 
CPU RAM
Fast virtual machine 
High level code (Java, Smalltalk ...) 
Compiler 
Bytecode VM 
Bytecode 
Interpreter 
JIT 
Compiler 
Memory Manager 
CPU RAM
Efficient JIT compiler 
display: listOfDrinks 
listOfDrinks do: [ :drink | 
self displayOnScreen: drink ] 
Execution 
number 
time to 
run (ms) Comments 
1 1 lookup of #displayOnScreen (cache) and byte code interpretation 
2 to 6 0,5 byte code interpretation 
7 2 generation of native code for displayOnScreen and native code run 
8 to 999 0,01 nat•ive code run 
1000 2 adaptive recompilation based on runtime type information, generation 
of native code and optimized native code run 
1000 + 0,002 optimized native code run
In Cog 
display: listOfDrinks 
listOfDrinks do: [ :drink | 
self displayOnScreen: drink ] 
Execution 
number 
time to 
run (ms) Comments 
1 1 lookup of #displayOnScreen (cache) and byte code interpretation 
2 to 6 0,5 byte code interpretation 
7 2 generation of native code for display and native code run 
8 to 999 0,01 nat•ive code run 
1000 2 adaptive recompilation based on runtime type information, generation 
of native code and optimized native code run 
1000 + 0,002 optimized native code run
A look into webkit 
• Webkit Javascript engine 
• LLInt = Low Level Interpreter 
• DFG JIT = Data Flow Graph JIT
Webkit JS benchs
In Cog
What is Sista ? 
• Implementing the next JIT optimization 
level
Goals 
• Smalltalk performance 
• Code readability
Smalltalk performance 
The Computer Language Benchmarks Game
Smalltalk performance 
The Computer Language Benchmarks Game
Smalltalk performance 
The Computer Language Benchmarks Game 
Smalltalk is 4x~25x slower than Java
Smalltalk performance 
The Computer Language Benchmarks Game 
Smalltalk is 4x~25x slower than Java 
Our goal is 3x faster: 
1.6x~8x times slower than Java 
+ Smalltalk features
Code Readability 
• Messages optimized by the bytecode 
compiler overused in the kernel 
• #do: => #to:do:
Adaptive recompilation 
• Recompiles on-the-fly portion of code 
frequently used based on the current 
environment and previous executions
Optimizing a method
Example
Example 
• Executing #display: with over 30 000 
different drinks ...
Hot spot detector 
• Detects methods frequently used
Hot spot detector 
• JIT adds counters on machine code 
• Counters are incremented when code 
execution reaches it 
• When a counter reaches threshold, the 
optimizer is triggered
Example 
Cannot detect hot spot 
Can detect hot spot 
(#to:do: compiled inlined)
Hot spot detected 
Over 30 000 executions
Optimizer 
• What to optimize ?
Optimizer 
• What to optimize ? 
• Block evaluation is costly
Optimizer 
• What to optimize ? 
Stack frame 
#display: 
Stack frame 
#do: 
Stack 
growing 
Hot spot down 
detected 
here
Optimizer 
• What to optimize ? 
Stack frame 
#display: 
Stack frame 
#do: 
Hot spot 
detected 
here
Find the best method
Find the best method 
• To be able to optimize the 
block activation, we need 
to optimize both 
#example and #do:
Inlining 
• Replaces a function call by its callee
Inlining 
• Replaces a function call by its callee 
• Speculative: what if 
listOfDrinks is not an 
Array anymore ?
Inlining 
• Replaces a function call by its callee 
• Speculative: what if 
listOfDrinks is not an 
Array anymore ? 
• Type-feedback from 
inline caches
Guard 
• Guard checks: listOfDrinks hasClass: Array 
• If a guard fails, the execution stack is 
dynamically deoptimized 
• If a guard fails more than a threshold, the 
optimized method is uninstalled
Dynamic deoptimization 
• On Stack replacement 
• PCs, variables and methods are mapped. 
Stack frame 
#display: 
Stack frame 
#do: 
Stack frame 
#optimizedDisplay:
Optimizations 
• 1) #do: is inlined into #display:
Optimizations 
• 2) Block evaluation is inlined
Optimizations 
• 3) at: is optimized 
• at: optimized ???
At: implementation 
• VM implementation 
• Is index an integer ? 
• Is object a variable-sized object, a byte 
object, ... ? (Array, ByteArray, ... ?) 
• Is index within the bound of the object ? 
• Answers the value
Optimizations 
• 3) at: is optimized 
• index isSmallInteger 
• 1 <= index <= listOfDrinks size 
• listOfDrinks class == Array 
• uncheckedAt1: (at: for variable size objects with in-bounds 
integer argument)
Restarting 
• On Stack replacement 
Stack frame 
#display: 
Stack frame 
#do: 
Stack frame 
#optimizedDisplay:
Our approach
In-image Optimizer 
• Inputs 
• Stack with hot compiled method 
• Branch and type information 
• Actions 
• Generates and installs an optimized compiled method 
• Generates deoptimization metadata 
• Edit the stack to use the optimized compiled method
In-image Deoptimizer 
• Inputs 
• Stack to deoptimize (failing guard, 
debugger, ...) 
• Deoptimization metadata 
• Actions 
• Deoptimize the stack 
• May discard the optimized method
Advantages 
• Optimizer / Deoptimizer in smalltalk 
• Easier to debug and program in Smalltalk 
than in Slang / C 
• Editable at runtime 
• Lower engineering cost
Advantages 
On Stack replacement done with Context manipulation 
Stack frame 
#display: 
Stack frame 
#do: 
Stack frame 
#optimizedDisplay:
Cons 
• What if the optimizer is triggered while 
optimizing ?
Advantages 
• CompiledMethod to optimized CompiledMethod 
• Snapshot saves compiled methods
Cons 
• Some optimizations are difficult 
• Instruction selection 
• Instruction scheduling 
• Register allocation
Critical optimizations 
• Inlining (Methods and Closures) 
• Specialized at: and at:put: 
• Specialized arithmetic operations
Interface VM - Image 
• Extended bytecode set 
• CompiledMethod introspection primitive 
• VM callback to trigger optimizer /deoptimizer
Extended bytecode set 
• Guards 
• Specialized inlined primitives 
• at:, at:put: 
• +, - , <=, =, ...
Introspection primitive 
• Answers 
• Type info for each message send 
• Branch info for each conditional jump 
• Answers nothing if method not in machine 
code zone
VM callback 
• Selector in specialObjectsArray 
• Sent to the active context when hot spot / 
guard failure detected
Stability 
• Low engineering resources 
• No thousands of human testers
Stability 
• Gemstone style ? 
• Large test suites
Stability 
• RMOD research team 
• Inventing new validation techniques 
• Implementing state-of-the-art validators
Stability goal 
• Both bench and large test suite run on CI 
• Anyone could contribute
Anyone can contribute
Anyone can contribute
Stability goal 
• Both bench and large test suite run on CI 
• Anyone could contribute
Status 
• A full round trip works 
• Hot spot detected in the VM 
• In-image optimizer finds a method to 
optimize, optimizes it an install it 
• method and closure inlining 
• Stack dynamic deoptimization
Status: hot spot detector 
• Richards benchmark 
• Cog: 341ms 
• Cog + hot spot detector: 351ms 
• 3% overhead on Richards 
• Detects hot spots 
• Branch counts ⇒ basic block counts
Next steps 
• Dynamic deoptimization of closures is not 
stable enough 
• Efficient new bytecode instructions 
• Stabilizing bounds check elimination 
• lowering memory footprint 
• Invalidation of optimized methods 
• On stack replacement
Thanks 
• Stéphane Ducasse 
• Marcus Denker 
• Yaron Kashai
Conclusion 
• We hope to have a prototype running for 
Christmas 
• We hope to push it to production in 
around a year
Demo 
...
Questions

More Related Content

What's hot

Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
craig lehmann
 
Automation: from local test to production deploy - 2020-11-05
Automation: from local test to production deploy - 2020-11-05Automation: from local test to production deploy - 2020-11-05
Automation: from local test to production deploy - 2020-11-05
Alessandra Bilardi
 
Leveraging HP Performance Center
Leveraging HP Performance CenterLeveraging HP Performance Center
Leveraging HP Performance Center
Martin Spier
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
Jonas Brømsø
 
Using Apache Camel as AKKA
Using Apache Camel as AKKAUsing Apache Camel as AKKA
Using Apache Camel as AKKA
Johan Edstrom
 
Real-Time Voice Actuation
Real-Time Voice ActuationReal-Time Voice Actuation
Real-Time Voice Actuation
Pragya Agrawal
 
Take a Look at Akka+Java (English version)
Take a Look at Akka+Java (English version)Take a Look at Akka+Java (English version)
Take a Look at Akka+Java (English version)
GlobalLogic Ukraine
 
TestIstanbul 2015
TestIstanbul 2015TestIstanbul 2015
TestIstanbul 2015
Martin Spier
 
Craftsmanship Workshop: Coding Kata
Craftsmanship Workshop: Coding KataCraftsmanship Workshop: Coding Kata
Craftsmanship Workshop: Coding Kata
Michael Ibarra
 
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Dakiry
 
Scaling tappsi
Scaling tappsiScaling tappsi
Scaling tappsi
Óscar Andrés López
 
Hystrix
HystrixHystrix
Hystrix
Diego Pacheco
 
Lock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesLock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin Coroutines
Roman Elizarov
 
Optimizing Java Notes
Optimizing Java NotesOptimizing Java Notes
Optimizing Java Notes
Adam Feldscher
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applications
Ruslan Shevchenko
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
Gal Marder
 
Ruby performance - The low hanging fruit
Ruby performance - The low hanging fruitRuby performance - The low hanging fruit
Ruby performance - The low hanging fruit
Bruce Werdschinski
 
Introduction to ACI APIs
Introduction to ACI APIsIntroduction to ACI APIs
Introduction to ACI APIs
Cisco DevNet
 
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor BuzatovićJavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 

What's hot (20)

Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
 
Automation: from local test to production deploy - 2020-11-05
Automation: from local test to production deploy - 2020-11-05Automation: from local test to production deploy - 2020-11-05
Automation: from local test to production deploy - 2020-11-05
 
Leveraging HP Performance Center
Leveraging HP Performance CenterLeveraging HP Performance Center
Leveraging HP Performance Center
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Using Apache Camel as AKKA
Using Apache Camel as AKKAUsing Apache Camel as AKKA
Using Apache Camel as AKKA
 
Real-Time Voice Actuation
Real-Time Voice ActuationReal-Time Voice Actuation
Real-Time Voice Actuation
 
Take a Look at Akka+Java (English version)
Take a Look at Akka+Java (English version)Take a Look at Akka+Java (English version)
Take a Look at Akka+Java (English version)
 
TestIstanbul 2015
TestIstanbul 2015TestIstanbul 2015
TestIstanbul 2015
 
Craftsmanship Workshop: Coding Kata
Craftsmanship Workshop: Coding KataCraftsmanship Workshop: Coding Kata
Craftsmanship Workshop: Coding Kata
 
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
 
Scaling tappsi
Scaling tappsiScaling tappsi
Scaling tappsi
 
Hystrix
HystrixHystrix
Hystrix
 
Lock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesLock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin Coroutines
 
Optimizing Java Notes
Optimizing Java NotesOptimizing Java Notes
Optimizing Java Notes
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applications
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
 
Ruby performance - The low hanging fruit
Ruby performance - The low hanging fruitRuby performance - The low hanging fruit
Ruby performance - The low hanging fruit
 
Introduction to ACI APIs
Introduction to ACI APIsIntroduction to ACI APIs
Introduction to ACI APIs
 
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor BuzatovićJavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
 

Similar to Sista: Improving Cog’s JIT performance

Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"
Fwdays
 
OrigoDB - take the red pill
OrigoDB - take the red pillOrigoDB - take the red pill
OrigoDB - take the red pill
Robert Friberg
 
SPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic librarySPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic library
AdaCore
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey Kovalenko
Valeriia Maliarenko
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
Speedment, Inc.
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
Malin Weiss
 
The Diabolical Developers Guide to Performance Tuning
The Diabolical Developers Guide to Performance TuningThe Diabolical Developers Guide to Performance Tuning
The Diabolical Developers Guide to Performance Tuning
jClarity
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
Speedment, Inc.
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
Speedment, Inc.
 
White and Black Magic on the JVM
White and Black Magic on the JVMWhite and Black Magic on the JVM
White and Black Magic on the JVM
Ivaylo Pashov
 
Episode 20 - Trigger Frameworks in Salesforce
Episode 20 - Trigger Frameworks in SalesforceEpisode 20 - Trigger Frameworks in Salesforce
Episode 20 - Trigger Frameworks in Salesforce
Jitendra Zaa
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
CassandraSummit2015_Cassandra upgrades at scale @ NETFLIX
CassandraSummit2015_Cassandra upgrades at scale @ NETFLIXCassandraSummit2015_Cassandra upgrades at scale @ NETFLIX
CassandraSummit2015_Cassandra upgrades at scale @ NETFLIX
Vinay Kumar Chella
 
Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native Compiler
Simon Ritter
 
CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019
Olivera Milenkovic
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
Martin Gutenbrunner
 
Performance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons LearnedPerformance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons Learned
Tim Callaghan
 
DEF CON 27 - CHRISTOPHER ROBERTS - firmware slap
DEF CON 27 - CHRISTOPHER ROBERTS - firmware slapDEF CON 27 - CHRISTOPHER ROBERTS - firmware slap
DEF CON 27 - CHRISTOPHER ROBERTS - firmware slap
Felipe Prado
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the Cloud
Jim Driscoll
 
Managing Millions of Tests Using Databricks
Managing Millions of Tests Using DatabricksManaging Millions of Tests Using Databricks
Managing Millions of Tests Using Databricks
Databricks
 

Similar to Sista: Improving Cog’s JIT performance (20)

Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"
 
OrigoDB - take the red pill
OrigoDB - take the red pillOrigoDB - take the red pill
OrigoDB - take the red pill
 
SPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic librarySPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic library
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey Kovalenko
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
The Diabolical Developers Guide to Performance Tuning
The Diabolical Developers Guide to Performance TuningThe Diabolical Developers Guide to Performance Tuning
The Diabolical Developers Guide to Performance Tuning
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
White and Black Magic on the JVM
White and Black Magic on the JVMWhite and Black Magic on the JVM
White and Black Magic on the JVM
 
Episode 20 - Trigger Frameworks in Salesforce
Episode 20 - Trigger Frameworks in SalesforceEpisode 20 - Trigger Frameworks in Salesforce
Episode 20 - Trigger Frameworks in Salesforce
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
CassandraSummit2015_Cassandra upgrades at scale @ NETFLIX
CassandraSummit2015_Cassandra upgrades at scale @ NETFLIXCassandraSummit2015_Cassandra upgrades at scale @ NETFLIX
CassandraSummit2015_Cassandra upgrades at scale @ NETFLIX
 
Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native Compiler
 
CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
 
Performance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons LearnedPerformance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons Learned
 
DEF CON 27 - CHRISTOPHER ROBERTS - firmware slap
DEF CON 27 - CHRISTOPHER ROBERTS - firmware slapDEF CON 27 - CHRISTOPHER ROBERTS - firmware slap
DEF CON 27 - CHRISTOPHER ROBERTS - firmware slap
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the Cloud
 
Managing Millions of Tests Using Databricks
Managing Millions of Tests Using DatabricksManaging Millions of Tests Using Databricks
Managing Millions of Tests Using Databricks
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
ESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
ESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
ESUG
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
ESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
ESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
ESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
ESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
ESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
ESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
ESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
ESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
ESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
ESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
ESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
ESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
ESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
ESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Recently uploaded

UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
AnkitaPandya11
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
kalichargn70th171
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
YAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring detailsYAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring details
NishanthaBulumulla1
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 

Recently uploaded (20)

UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
YAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring detailsYAML crash COURSE how to write yaml file for adding configuring details
YAML crash COURSE how to write yaml file for adding configuring details
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 

Sista: Improving Cog’s JIT performance

  • 1. Sista: Improving Cog’s JIT performance Clément Béra
  • 2. Main people involved in Sista • Eliot Miranda • Over 30 years experience in Smalltalk VM • Clément Béra • 2 years engineer in the Pharo team • Phd student starting from october
  • 3. Cog ? • Smalltalk virtual machine • Runs Pharo, Squeak, Newspeak, ...
  • 4. Plan • Efficient VM architecture (Java, C#, ...) • Sista goals • Example: optimizing a method • Our approach • Status
  • 5. Virtual machine High level code (Java, Smalltalk ...) Runtime environment (JRE, JDK, Object engine...) CPU: intel, ARM ... - OS: Windows, Android, Linux ..
  • 6. Basic Virtual machine High level code (Java, Smalltalk ...) Compiler Bytecode VM Bytecode Interpreter Memory Manager CPU RAM
  • 7. Fast virtual machine High level code (Java, Smalltalk ...) Compiler Bytecode VM Bytecode Interpreter JIT Compiler Memory Manager CPU RAM
  • 8. Efficient JIT compiler display: listOfDrinks listOfDrinks do: [ :drink | self displayOnScreen: drink ] Execution number time to run (ms) Comments 1 1 lookup of #displayOnScreen (cache) and byte code interpretation 2 to 6 0,5 byte code interpretation 7 2 generation of native code for displayOnScreen and native code run 8 to 999 0,01 nat•ive code run 1000 2 adaptive recompilation based on runtime type information, generation of native code and optimized native code run 1000 + 0,002 optimized native code run
  • 9. In Cog display: listOfDrinks listOfDrinks do: [ :drink | self displayOnScreen: drink ] Execution number time to run (ms) Comments 1 1 lookup of #displayOnScreen (cache) and byte code interpretation 2 to 6 0,5 byte code interpretation 7 2 generation of native code for display and native code run 8 to 999 0,01 nat•ive code run 1000 2 adaptive recompilation based on runtime type information, generation of native code and optimized native code run 1000 + 0,002 optimized native code run
  • 10. A look into webkit • Webkit Javascript engine • LLInt = Low Level Interpreter • DFG JIT = Data Flow Graph JIT
  • 13. What is Sista ? • Implementing the next JIT optimization level
  • 14. Goals • Smalltalk performance • Code readability
  • 15. Smalltalk performance The Computer Language Benchmarks Game
  • 16. Smalltalk performance The Computer Language Benchmarks Game
  • 17. Smalltalk performance The Computer Language Benchmarks Game Smalltalk is 4x~25x slower than Java
  • 18. Smalltalk performance The Computer Language Benchmarks Game Smalltalk is 4x~25x slower than Java Our goal is 3x faster: 1.6x~8x times slower than Java + Smalltalk features
  • 19. Code Readability • Messages optimized by the bytecode compiler overused in the kernel • #do: => #to:do:
  • 20. Adaptive recompilation • Recompiles on-the-fly portion of code frequently used based on the current environment and previous executions
  • 23. Example • Executing #display: with over 30 000 different drinks ...
  • 24. Hot spot detector • Detects methods frequently used
  • 25. Hot spot detector • JIT adds counters on machine code • Counters are incremented when code execution reaches it • When a counter reaches threshold, the optimizer is triggered
  • 26. Example Cannot detect hot spot Can detect hot spot (#to:do: compiled inlined)
  • 27. Hot spot detected Over 30 000 executions
  • 28. Optimizer • What to optimize ?
  • 29. Optimizer • What to optimize ? • Block evaluation is costly
  • 30. Optimizer • What to optimize ? Stack frame #display: Stack frame #do: Stack growing Hot spot down detected here
  • 31. Optimizer • What to optimize ? Stack frame #display: Stack frame #do: Hot spot detected here
  • 32. Find the best method
  • 33. Find the best method • To be able to optimize the block activation, we need to optimize both #example and #do:
  • 34. Inlining • Replaces a function call by its callee
  • 35. Inlining • Replaces a function call by its callee • Speculative: what if listOfDrinks is not an Array anymore ?
  • 36. Inlining • Replaces a function call by its callee • Speculative: what if listOfDrinks is not an Array anymore ? • Type-feedback from inline caches
  • 37. Guard • Guard checks: listOfDrinks hasClass: Array • If a guard fails, the execution stack is dynamically deoptimized • If a guard fails more than a threshold, the optimized method is uninstalled
  • 38. Dynamic deoptimization • On Stack replacement • PCs, variables and methods are mapped. Stack frame #display: Stack frame #do: Stack frame #optimizedDisplay:
  • 39. Optimizations • 1) #do: is inlined into #display:
  • 40. Optimizations • 2) Block evaluation is inlined
  • 41. Optimizations • 3) at: is optimized • at: optimized ???
  • 42. At: implementation • VM implementation • Is index an integer ? • Is object a variable-sized object, a byte object, ... ? (Array, ByteArray, ... ?) • Is index within the bound of the object ? • Answers the value
  • 43. Optimizations • 3) at: is optimized • index isSmallInteger • 1 <= index <= listOfDrinks size • listOfDrinks class == Array • uncheckedAt1: (at: for variable size objects with in-bounds integer argument)
  • 44. Restarting • On Stack replacement Stack frame #display: Stack frame #do: Stack frame #optimizedDisplay:
  • 46. In-image Optimizer • Inputs • Stack with hot compiled method • Branch and type information • Actions • Generates and installs an optimized compiled method • Generates deoptimization metadata • Edit the stack to use the optimized compiled method
  • 47. In-image Deoptimizer • Inputs • Stack to deoptimize (failing guard, debugger, ...) • Deoptimization metadata • Actions • Deoptimize the stack • May discard the optimized method
  • 48. Advantages • Optimizer / Deoptimizer in smalltalk • Easier to debug and program in Smalltalk than in Slang / C • Editable at runtime • Lower engineering cost
  • 49. Advantages On Stack replacement done with Context manipulation Stack frame #display: Stack frame #do: Stack frame #optimizedDisplay:
  • 50. Cons • What if the optimizer is triggered while optimizing ?
  • 51. Advantages • CompiledMethod to optimized CompiledMethod • Snapshot saves compiled methods
  • 52. Cons • Some optimizations are difficult • Instruction selection • Instruction scheduling • Register allocation
  • 53. Critical optimizations • Inlining (Methods and Closures) • Specialized at: and at:put: • Specialized arithmetic operations
  • 54. Interface VM - Image • Extended bytecode set • CompiledMethod introspection primitive • VM callback to trigger optimizer /deoptimizer
  • 55. Extended bytecode set • Guards • Specialized inlined primitives • at:, at:put: • +, - , <=, =, ...
  • 56. Introspection primitive • Answers • Type info for each message send • Branch info for each conditional jump • Answers nothing if method not in machine code zone
  • 57. VM callback • Selector in specialObjectsArray • Sent to the active context when hot spot / guard failure detected
  • 58. Stability • Low engineering resources • No thousands of human testers
  • 59. Stability • Gemstone style ? • Large test suites
  • 60. Stability • RMOD research team • Inventing new validation techniques • Implementing state-of-the-art validators
  • 61. Stability goal • Both bench and large test suite run on CI • Anyone could contribute
  • 64. Stability goal • Both bench and large test suite run on CI • Anyone could contribute
  • 65. Status • A full round trip works • Hot spot detected in the VM • In-image optimizer finds a method to optimize, optimizes it an install it • method and closure inlining • Stack dynamic deoptimization
  • 66. Status: hot spot detector • Richards benchmark • Cog: 341ms • Cog + hot spot detector: 351ms • 3% overhead on Richards • Detects hot spots • Branch counts ⇒ basic block counts
  • 67. Next steps • Dynamic deoptimization of closures is not stable enough • Efficient new bytecode instructions • Stabilizing bounds check elimination • lowering memory footprint • Invalidation of optimized methods • On stack replacement
  • 68. Thanks • Stéphane Ducasse • Marcus Denker • Yaron Kashai
  • 69. Conclusion • We hope to have a prototype running for Christmas • We hope to push it to production in around a year