SystemEditor is a library to model code changes within squeak, and load them atomically.




Atomic loading is a feature Colin Putney implemented for MC2, then released as a separate, quite unstable library: SystemEditor


Goran and I picked up this library as a core component of DeltaStreams, and we fixed many bugs it had with loading different combinations of things, due to not being tested in production. In the meantime, Keith Hodges wrote a new package loader for Monticello 1.5 that hooked into SystemEditor to take advantage of it's atomic loading property. It hardly worked at all, but the principle was there. See the class MCPackageLoader2 in Monticello 1.5:


I have since stopped working on DeltaStreams and started working heavily with Keith in improving the basic tools in the image and making new ones. Since I was already familiar with SystemEditor due to my work on DeltaStreams, I volunteered to work on package loader 2. I fixed a dozen or so bugs in both package loader 2 and SystemEditor, and now it is able to load quite a few packages. It is still beta phase though. It is not yet able to cope with the following:



I'm fixing those inadequacies in the order listed. Once they are fixed, we will release PackageLoader2 as the default in Monticello, and increment the version number of Monticello to 1.6.


How it works


SystemEditor has a set of classes (editor classes) that respond to the same protocol as Class, Metaclass, MethodDictionary, ClassOrganizer, SystemDictionary, and other related core classes. Each one acts as an "editor" on an existing object in the system. These editors respond to the same protocol as the object they edit, but maintain changes internally, usually as a list of additions/removals. When the time comes to commit the changes (See SystemEditor>>commit), all these editors are passed a MigrationTransaction object, and are asked to submit the old and new copy of the object they are editing, which will be swapped at commit time. When all objects have done this, MigrationTransaction builds two arrays: one of old objects, and one of new, and invokes the primitive Array>>exchangeElementIdentityWith: , which does a bulk identity swap (see MigrationTransaction>>commit). Everything that needs to change is swapped: Recompiled classes, instances of those classes, new methodDictionaries for classes that don't need recompiling, Smalltalk, the SystemDictionary instance, ClassOrganization instances, and so on, all during one primitive.




I'm fairly confident in Monticello1.6-beta, as it currently exists. I use it as my default loader in all of my images, except when I am dealing with Tweak in my croquet images.


To try it out, do the following:

HTTPSocket httpFileIn: ''.

Installer install: 'Monticello16-Beta'


This loads LevelPlayingField (= Installer and MC1.5) and then runs my script to load SystemEditor and activate PackageLoader2.