A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A...
Transcript of A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A...
![Page 1: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/1.jpg)
A Tour to Spur forNon-VM Experts
Guille Polito, Christophe DemareyESUG 2016, 22/08, Praha
![Page 2: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/2.jpg)
From a user point of view
We are working on the new Pharo Kernel
● Bootstrap: create an image from scratch- Classes- Global objects- Processes and contexts
● Image Initialization: What is the correct order?
BTW, see our talk on this ;)Mission Pharo Kernel, Thursday 10 am
![Page 3: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/3.jpg)
What is this talk about?
Dec 14, 2015; 11:08am[IMPORTANT] Starting migration to SpurVM
![Page 4: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/4.jpg)
Initial Motivation to look into Spur
1) How do we move to Spuras fast as possible?
2) Should we /How do we adapt to it?
3) What are the risks?
![Page 5: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/5.jpg)
Motivation of this talk #1: Education
Explain what is Spur
Determine if a problem comes from image side or VM side?
![Page 6: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/6.jpg)
Motivation of this talk #2:Understanding the Impact
Is my application compatible?
Will It break? Do I have to port it?
![Page 7: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/7.jpg)
Part 1:Demolishing Myths
![Page 8: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/8.jpg)
What is Spur?
![Page 9: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/9.jpg)
Spur is not a new Virtual Machine
Its underlying execution engine is the same as in Cog (same bytecode, same interpreter, same JIT compiler)
![Page 10: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/10.jpg)
Spur is not a new Garbage Collector
It just implements a new garbage collector (which, BTW, is not new...)
![Page 11: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/11.jpg)
Spur is not a new Object Format.
It just implements a new object format (which, BTW, is just the means to an end)
![Page 12: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/12.jpg)
So... what is Spur?
Spur is a new Memory Manager for Cog VM.
- New object representation in memory (that allows ephemerons, pinned objects,...)
- New memory organization of Pharo images (that allows to better manage resources)
![Page 13: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/13.jpg)
![Page 14: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/14.jpg)
Spur in a Nutshell
It's a Cog VM
+ 64 bits support
+ faster: x1.8 speedup
+ larger images (> 2 Go)
+ ephemeron support
and more ...
![Page 15: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/15.jpg)
Spur > 64-bits support
● No more need to install 32-bits libraries
● Images with size > 2 Go
![Page 16: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/16.jpg)
Spur > faster access to classes Class Table
● Direct access toclass objects
0
1
2
3
4
5
6
7
8
Array (hash=0)
String (hash=6)
Next page...
![Page 17: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/17.jpg)
Spur > faster Garbage Collector
● “Young objects die young (and fast)”
● Added survivor segments (future and past) tothe young space => allows more minor GC instead of major GC
future
Old space Young Space
past
eden
Major GC (mark & sweep)Minor GC
(scavenger)
![Page 18: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/18.jpg)
Spur > Fast become
No more hangs in large images when using #become:
(e.g. Moose with a big famix model)
Why? Spur introduces forwarders
● prevents to scan the whole memory
● replaces pointers when they are accessed
● implemented by a partial read barrier1
Cheap in most cases (just one indirection)
Costly if you rely a lot on primitives fallback
1. Eliot Miranda, Clément Bera. A Partial Read Barrier for Efficient Supportof Live Object-Oriented Programming. ISMM'15
![Page 19: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/19.jpg)
Spur > fasterImmediate objects
New immediate objects
● Character
● Float (only 64-bits)
Speed-up in wide strings
Speed-up in float arithmetic and memory saving
![Page 20: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/20.jpg)
Spur > other features
Spur object format:
● All classes are compact => only two kind of headers (3 before Spur)
● Support for pinned-objects (see UFFI talk on Friday)
● Ongoing support of read-only objects
● Still 2 unused bits
![Page 21: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/21.jpg)
Spur > scalability
● Memory is now divided in several segments
● No more need to have a contiguous chunk ofmemory
Memorysegment
Memorysegment
Memorysegment
Memorysegment
![Page 22: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/22.jpg)
Spur > reliability
● Ephemeron finalization support
● Avoid memory leaks
BTW, see our OTHER talk on this ;)A Weak Pharo story, Thursday, 3 pm
![Page 23: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/23.jpg)
Part 2:Porting applications and
frameworks to Spur
Cog
Spur
![Page 24: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/24.jpg)
How do I portmy application
to Spur?
![Page 25: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/25.jpg)
Porting Applications
![Page 26: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/26.jpg)
Porting Applications
![Page 27: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/27.jpg)
Porting Applications
![Page 28: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/28.jpg)
Porting Applications
Okay, maybe just wait that your developer friendsport your favorite frameworks.
![Page 29: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/29.jpg)
Porting Frameworks/Libraries
![Page 30: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/30.jpg)
Porting Basics #1
The number hierarchy changed
● Beware if you have visitors
● Beware if you have overrides
Porting Frameworks/Libraries
![Page 31: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/31.jpg)
Porting Basics #2
Character is now immediate
● Beware if you have overrides that use the
internal state
Porting Frameworks/Libraries
![Page 32: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/32.jpg)
Porting Basics #3
New (enhanced) ephemeron finalization
● If you need finalization you'll probably want to
use the new one
BTW, see our OTHER talk on this ;)
Porting Frameworks/Libraries
A Weak Pharo story, Thursday, 3 pm
![Page 33: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/33.jpg)
Porting Basics #4
Native Boost is being deprecated
● If you are using FFI, you will need to review your
bindings
Porting Frameworks/Libraries
Native Boost UFFI
![Page 34: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/34.jpg)
Spur Behind the Scenes
![Page 35: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/35.jpg)
VM development hosted on GitHub:OpenSmalltalk / opensmalltalk-vm
![Page 36: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/36.jpg)
Why is it a good news?
● Brings together the VM community
● Easier to contribute
– Pull requests
– Issue tracker
– Documentation:https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/CONTRIBUTING.md
![Page 37: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/37.jpg)
VM build all flavors throughTravis CI
Still missing VM tests. Upcoming?
![Page 38: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/38.jpg)
Where to find VM binaries?
● Pharo
http://files.pharo.org/vm/
Squeak, NewSpeak
https://bintray.com/opensmalltalk/vm/cog
![Page 40: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/40.jpg)
Should I move to Spur?
BounceBubbleSort
DeltaBlueFannkuch
GraphSearchJson
MandelbrotNbody
PageRankPermute
QueensQuickSort
SieveStorage
Towers
0
0,2
0,4
0,6
0,8
1
1,2
1,4
1,6
1,8
Pre-Spur
Spur
by Stefan Marr, Apr 06, 2015
![Page 41: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/41.jpg)
Should I move to Spur?
✔ 64-bits support
✔ Increased performances: x1.8 speedup
✔ Scalability, Reliability and open to newfeatures
– image not compacting anymore (will be fixed soon)
![Page 42: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/42.jpg)
EXTRA SLIDES!
![Page 43: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/43.jpg)
1) Class tables
2) Forwarders
3) Ephemeron Finalization
4) The Scavenger GC
Dissecting Spur...
![Page 44: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/44.jpg)
Chapter 1Classes are in Tables
(and they hide in tables)
![Page 45: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/45.jpg)
1.1 The old object header...
![Page 46: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/46.jpg)
1.1 Compact classes
Smalltalk compactClassesArray
![Page 47: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/47.jpg)
1.1 Cons of the old object header
● A full word is used to indicate an object's class
– 4G classes in 32 bits
– 16E (2^60) classes in 64 bits (!!)
● Three different headers => checks for the header type are common
![Page 48: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/48.jpg)
1.2 New class header
![Page 49: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/49.jpg)
1.2 Class table
0
1
2
3
4
5
6
7
8
Array (hash=0)
String (hash=6)
Next page...
![Page 50: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/50.jpg)
1.2 Class table
class idx = 0
0
1
2
3
4
5
6
7
8
Array (hash=0)
String (hash=6)
Next page...
![Page 51: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/51.jpg)
1.2 Pros of the new object header
● 2^22 classes (4M). Still enough and efficient.
● Compatible with 64bits
● All classes are compact => only two kind of headers
![Page 52: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/52.jpg)
1.2 Hidden objects
0
1
2
3
4
5
6
7
8
Array (hash=0)
String (hash=6)
Next page...
Class idx = 1
![Page 53: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/53.jpg)
1.2 Hidden objects?
● The class table is an object (and lives in the heap)
● Its class index is “hidden”:
– Array allInstances
will iterate objects by class index
● In the class table:
– Indexes 0-15 are reserved for tagged objects
– Indexes 16-32 are reserved for hidden classes
![Page 54: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/54.jpg)
1.3 Maintaining the class table
Classes are normal objects...
They are created with no special primitives...
But...
How does the VM know an object is a
class to put it into the class table?
![Page 55: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/55.jpg)
1.3 Identifying classes by definition
A class is an object that is instantiated:
A class enters the class tableupon instantiation
![Page 56: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/56.jpg)
1.3 But the index is the hash!
But... hashes are assigned lazily for all objects:
Classes, on instance-side,
define a special hash method
Behavior >> basicIdentityHash
<primitive: 175>self primitiveFailed
Object >> basicIdentityHash
<primitive: 75>self primitiveFailed
![Page 57: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/57.jpg)
Chapter 1 - Conclusions
● Classes are organized in tables
● All classes are compact
● Simpler object header
● Still place for 4M classes
● On the image side, is almost transparent
![Page 58: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/58.jpg)
Chapter 2The forwarder plague
![Page 59: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/59.jpg)
2.1 Become
● Swaps two objects
– (actually, swaps two object's identity)
● Useful for:
– Updating and migrating objects
– Install proxies
– Replace an object's behavior
![Page 60: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/60.jpg)
2.1 The old become
● Full scanned all memory
● And was SLOOOOOW
![Page 61: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/61.jpg)
2.1 Lazy become
ba
Eliot Miranda, Clément Bera. A Partial Read Barrier for EfficientSupport of Live Object-Oriented Programming. ISMM'15
![Page 62: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/62.jpg)
2.1 Lazy become
b becomeForward: a.
User's code
Eliot Miranda, Clément Bera. A Partial Read Barrier for EfficientSupport of Live Object-Oriented Programming. ISMM'15
ba
![Page 63: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/63.jpg)
2.1 Lazy become
Eliot Miranda, Clément Bera. A Partial Read Barrier for EfficientSupport of Live Object-Oriented Programming. ISMM'15
b becomeForward: a.
User's code
a forwarder!
![Page 64: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/64.jpg)
2.1 Lazy Become
Eliot Miranda, Clément Bera. A Partial Read Barrier for EfficientSupport of Live Object-Oriented Programming. ISMM'15
b becomeForward: a.b doSomething
User's code
a forwarder!
![Page 65: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/65.jpg)
2.2 The read barrier
● A full read barrier would be too expensive
– (on every read, on every primitive, on everymessage send...)
● The read barrier is implemented in two places:
– Message send lookup failure
– Primitive failure
Eliot Miranda, Clément Bera. A Partial Read Barrier for EfficientSupport of Live Object-Oriented Programming. ISMM'15
![Page 66: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/66.jpg)
2.2 Message send lookup failure
method := (self lookupSelector: selector inClass: class).
method ifNil: [
(receiver isForwarder) ifTrue: [
receiver := receiver forward. “scan also the objects in the stack” ].
method := (self lookupSelector: selector inClass: class).
].
Eliot Miranda, Clément Bera. A Partial Read Barrier for EfficientSupport of Live Object-Oriented Programming. ISMM'15
![Page 67: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/67.jpg)
2.2 Primitive failure
self performPrimitive: primitiveNumber.
self primitiveFailed ifTrue: [
“scan the stack looking for forwarders and retry”
self performPrimitive: primitiveNumber.
].
Eliot Miranda, Clément Bera. A Partial Read Barrier for EfficientSupport of Live Object-Oriented Programming. ISMM'15
![Page 68: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/68.jpg)
2 Conclusions
● Become does not need full scan anymore
● A forwarder replaces the object in place
● Two-way become copies object at the end
● Forwarders are bypassed using a partial read barrier:
– Message lookup failure
– Primitive failure
● No noticeable overhead
![Page 69: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/69.jpg)
3.5 Scavenger GC
● “Young Objects Die Young (and quick)”
● Young objects are created in eden
● Objects are “tenured” after surviving severalgenerations
● Tenured objects go to old space
![Page 70: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/70.jpg)
3.5 Scavenger GCOld space New Space
future past
eden
![Page 71: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/71.jpg)
3.5 Scavenger GCOld space New Space
future past
eden
● Mark and Sweep (marking collector)
● Runs “every blue moon” on the entire memory
● Slow
● Scavenger (copying collector)
● Runs often, only in new space
● Object tenure (to old space)
depends on the ratio of
allocation
![Page 72: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/72.jpg)
3.5 Scavenger GCNew Space
future past eden
1) Future is always empty during execution
![Page 73: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/73.jpg)
3.5 Scavenger GCNew Space
future past eden
1) Future is always empty during execution
2) On a GC, past and eden objects that are referenced are copied to future
![Page 74: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/74.jpg)
3.5 Scavenger GCNew Space
past future eden
1) Future is always empty during execution
2) On a GC, past and eden objects that are referenced are copied to future
3) Then, future and past spaces are swapped
![Page 75: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/75.jpg)
3.5 Scavenger GC
Two questions remain:
● How does the scavenger do a GC withoutiterating the entire heap?
● How does he know object ages?
![Page 76: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/76.jpg)
3.5 Scavenger GC
Two questions remain:
● How does the scavenger do a GC withoutiterating the entire heap?
● How does he know object ages?
It maintains a set of “objects in new space referenced from old space”
By their addresses! Lower addresses are younger....
![Page 77: A Tour to Spur for Non-VM Experts - esug.orgesug.org/data/ESUG2016/01-Monday/1400-1430 Spur... · A Tour to Spur for Non-VM Experts Guille Polito, Christophe Demarey ESUG 2016, 22/08,](https://reader034.fdocuments.us/reader034/viewer/2022042223/5ec9dabf23c48b12f13c35db/html5/thumbnails/77.jpg)
Is that all?
● Pinned objects?
● The finalization queue?
● Memory segments, bridges, …?
● (The not working) Memory compaction?
● New immediate objects?
● ...