You are a Smalltalker, a Pharoer or a Squeaker. Word has been that Eliot Miranda has implemented a new Memory Manager (Spur) for the Cog VM. You are wondering how it will change your work flow with your favorite Smalltalk dialect. This one page article was made for you.
1) Fast become: As you know Smalltalk features
become: which allows you to swap two objects in memory. This is used for example when you add an instance variable to a class, then all the class instances are migrated to support the extra instance variable field by becoming a new object with the same values but an extra slot. This operation used to be very slow, making large images hard to work with. It will now be much faster.
2) Ephemerons: You can now instantiate efficient Ephemerons. An Ephemeron is an object which refers strongly to its contents as long as the Ephemeron’s key is not garbage collected, and weakly from then on.
3) Pinned objects: You can now mark an object to have a fixed position in memory. Then this object will never be moved in the memory, the garbage collector will not move it. This simplifies some FFI (Foreign function interface) implementations.
4) Variable sized and segmented memory: The memory allocated in the operating system by the virtual machine will now grow and shrink according to the image size. Have you ever encountered an ‘out of memory’ error while reaching a 1 Gb image on your 8 Gb RAM computer ? This will not happen any more. In addition, the heap’s memory will be divided in several segments, making the allocation of big images simpler, especially on windows.
5) Object format 64 bit compatible: As you know the main Pharo and Squeak release are not yet 64 bit compatible. One main problem was the object format that was not 64 bit compatible and this problem is solved. The 64 bit VM is not ready, but a huge step in that direction was done. This means that in the very near future you should be able to use a 64 bit Stack VM.
6) Incremental and efficient garbage collector: Sometimes in big images (over 300Mb) the image become unresponsive during several seconds because the VM is performing a full garbage collect. Most of the time, the garbage collection will now be split in multiple steps, each step being fast to execute and being executed on a regular basis. Therefore, you will not have any more this full garbage collector pauses. In addition, the garbage collector is more efficient, meaning that big images (let’s say up to 1Gb) will be much faster and responsive.
7) Performance improvement: classic benchmarks are run around 35% faster with Spur as Cog’s memory manager. This is due to (from most to least important):
- the new GC has less overhead.
- the new object format speeds up some VM internal caches.
- characters are now immediate objects, which speeds up String accessing.
- the new object format has a larger hash which speeds up big hashed collections such as big sets and dictionaries.
- become is faster.
Expected dead lines
When will you be able to use Spur in your favorite Smalltalk dialect ?
- Pharo: Spur is currently planned for Pharo 4 (alpha version in April, beta version in december, release around April 2015). The first alpha version of Pharo 4 with Spur should be ready this summer.
- Squeak: Spur is planned for Squeak 5.
- NewSpeak: the deployment of Spur on NewSpeak is currently a work in progress.
Thanks Eliot for this new Memory Manager !