ImageSegments for real -- new VM / risky demo

Dan Ingalls Dan.Ingalls at disney.com
Thu Oct 7 04:54:13 UTC 1999


Folks -

It has been half a year since we introduced imageSegments to Squeak (updates 756 and 760 in March of this year.  In case you have not followed this, here is a summary...

ImageSegments are created by a primitive operation that very quickly identifies what objects are reachable for a given set of roots, and by no other path.  The primitive also copies the objects into a WordArray in the same form as they exist in the Squeak image itself, and copies into an Array all of the pointers from the segment into the rest of Squeak (ie the parts that are reachable from the outside).  Naturally there is an inverse operation that will recreate the entire structure in a twinkle from the segment.

If you put these two operations together, you get a high-performance deepCopy operation.  If you save the imageSegments on a local file, you get application overlaying, and if you send that file far away and read it into another image, you have export/import of Squeak worlds.  They are fast.  They are compact.  AND, they are platform-independent!  Imagine a DLL that you can use on Windows or a Mac or a bare chip.

Of course there is more to this technology.  For instance to swap out a segment, you must replace all its roots by ImageSegmentRootStubs.  These are special objects that will retrieve their segment if any message is sent to them, and even if they are classes and a message is sent to one of their instances.  Also, if you export an image segment, special work must be done when importing it to reconcile the outpointers with the state of the receiving system.  That work comprises much of the intelligence of SmartReferenceStreams. [more info in class comments to ImageSegment, ImageSegmentRootStub and SmartReferenceStream]

That's the background.  Ted Kaehler and I will be writing a paper on ImageSegments and their associated technology later this year.  But that's not why I'm writing this message.  The reason is that we have been beating on this code heavily in the last month, we have found a number of bugs, we have fixed them, and we now deem that ImageSegments are ready for serious test.

To become a tester of ImageSegments you will need to do two things:  back up all your work (duh), and get a new copy of the Squeak VM.  There is one for the Mac PPC available now in the Squeak 2.5 folder at UIUC, called:

	SqueakVM2.5cPPC.sea

Hopefully we will have others out soon for the other platforms.  Any Squeak with updates through 1523 should be capable of producing the interpreter file.

For our first real test of ImageSegments, we have implemented swapping of morphic projects.  Thus, if you have an up-to-date image with a lot of (morphic) projects in it, you can open the preferences panel and set #projectsSentToDisk to true.  Thereafter, every time you change projects, it will bring in the new project and send out up to two others.  Soon all your projects will be on disk, and your kernel image will be smaller.  To write all projects initially in one long pause (not necessary) do this:

	Project storeAllInSegments.

We have been testing this on a 70MB version of an image that Alan uses for a lot of his presentations.  After segmentation the image is only 18MB, and there is a companion folder of segments ranging from 20K up to 8MB, and totalling 52MB (natch).

Key to the effectiveness of this technique is that there be no pointers from "the outside" into the morphic world that comprises the project.  Anything pointed to directly or indirectly other than by the roots of the world will be excluded from the segment and will thus not get swapped out.

Note that if you start using imageSegments, a folder will appear on your disk named imageName_segs.  If you move or rename your image, this folder must accompany it and remain named correspondingly.

Have fun testing this, but remember:  You are testing.  This is a kernel mechanism -- if one bit is wrong your system will crash.  But we just found the last bug today.  We think.

Enjoy
	- Dan (and Ted)

PS:  Prior users of ImageSegments will definitely want to get the new VM.  If you experienced problems in the past, it is likely things will work better now.  We did find two fatal bugs in the last two weeks.





More information about the Squeak-dev mailing list