Saturday, January 04, 2014

2006-12-04: Smalltalk, the Image and Multiple CPUs

First posted on 2006-12-04:

Runar Jordahl posted about VisualWorks and multiple CPU cores, which is a subject that has interested me, so I felt I wanted to write something in response - not that I disagree with Runar at all, I am hopefully just re-enforcing what Runar has already said.

It used to be simple. A computer had a CPU that did the work supported by a host of other bits and pieces like memory, disks etc... Today computers are tending to have many CPUs. In the future they may well have swarms of CPUs each.

Smalltalk took shape in the 1970s, well before the advent of multi-core chips and most Smalltalk implementations, even today, run on a virtual machine that runs in a single operating system process using "green threads"; which means that the VM schedules the work in the image with only one Smalltalk process running at a time.

The memory space occupied by a running Smalltalk system is called an image and is much like the memory space occupied by any running program regardless of language , i.e. there is code and data in there. In Smalltalk it's all objects with some of the objects being code (byte codes). (As a bonus a Smalltalk image can be saved in a running state to be later resumed.)

Having a single image make use of many CPUs requires that the VM run more than one Smalltalk process at a time (typically as native threads) and allow the operating system to do the scheduling (sharing the CPUs among the processes). The problems here are that the running processes are operating on the same set of Objects (i.e. in the same image) so great care must be taken to ensure that the activities of one process do not interfere with or corrupt another and also that the timing of execution is out of the hands of the VM so things may not happen in a repeatable order (i.e. the system may become non-deterministic).

One way to address these issues is to avoid them. Don't run many processes in one image but rather run many images. In this way each image continues to run in a (largely) deterministic fashion using green threads. This solution can be inefficient in it's use of memory. The set of data being actively operated upon in an image is often a very small subset of the whole image so having many images means duplicating things unnecessarily, and while running two such images might be tolerable, running 10s or 100s would be crazy (I think we can expect servers to have 100s (or more) CPUs in the not too distant future).

Another approach is to use flags or semaphores to stop processes from stepping on each others toes. So, we could lock the root of an entire object model while our process is operating on it, thereby preventing any other process from making changes until our guy has finished - but this probably means processes will have to queue to get access to the model (even read access because we want to have read consistency) which means we really only have one process actively doing anything at a time. Back to square one. A variant of this is to make the locks more fine grained so that each process will only lock a part of the model allowing others to work on other parts of the model but this makes a system harder to code and debug, perhaps much harder.

How about if we could mix the above two solutions and have have many operating system processes all running Smalltalk in the same image and have a ready made mechanism to help avoid processes treading on each others toes?

Such a system already exists in GemStone which is both a Smalltalk implementation and a DBMS.

A running gemstone instance is a single Smalltalk image which is backed securely to disk (that's part of the database-ness of GemStone). Many operating system processes can be started in the context of this image and all of these share the same pool of objects via shared memory (this is the Shared Page Cache). Each of these processes may run at the same time on any number (well, up to ~2000 with the version of GemStone we use) of CPUs. Transactions prevent one process from treading on the toes of another (another bit of database-ness).

GemStone is an excellent environment for running headless applications such as web servers (e.g. the OpenSkills SkillsBase). If you need a GUI and also want to use lots of CPUs, GemStone can't help ... which brings us to exactly the same conclusion that Runar reached.

As GemStone demonstrates, transactional shared memory is a viable way to go. I too hope VisualWorks moves in this direction.

Re-posting the past

I used a different blogging system for a while several years ago, and I just found it again.  So I'll post those old articles here just so I have all my stuff in one heap.

Sunday, December 16, 2012

A letter to my MP about medical data standards


Dear Mark Field,

My wife and I have recently attended hospitals to have medical scans.  The pattern these days seems to be to hand people a CD containing the images.  All good, except the images are in a proprietary format which is not so good as it means we can't view the scan images.

This points to a wider issue.  The medical industry lacks open data standards.  They have heaps of things which pretend to be standards (described as 'de-facto' or similar), but few if any real ISO style standards.  It is counter-productive to impose requirements for specific software (as we have seen with various NHS software system disasters), but it would be a big positive to legislate standards for data.  As an example of how well data standards can work, look at your mobile phone:  in Europe phones had to follow the GSM standard and that now means I can pick any phone to use with any provider ... I just swap the *standard* SIM from one device to another, or use the same device with a different SIM.  Back to medical standards; I suggest that medical images be presented in a standard format (TIFF, PNG - something non-lossy like that) and that medical data (meta-data, i.e. data about the image) be included along-side using XML or similar, but whatever standard is chosen it should be *open* and easy for equipment manufacturers to work with and for patients (and doctors!) to view the data. (I recently met with a doctor and he was unable to view the images of my scans because the software he had would not work with the images I had been given).

The money recently wasted on NHS systems was wasted because the focus was on *systems* not on data format standards.  It's as if the NHS spent money on making the perfect phone rather than defining GSM. The NHS spectacularly (if unsurprisingly) failed to make the perfect fits-all-needs system, but they could have defined a first version of a standard interchangeable patient record, or even just how medial image data would be exchanged.  With standard(s) in place the software industry could then step in to implement competing systems (built on their own dime, much as phone companies make phones on their own dime) which the medical industry could use to manage and view patient data.

If there was a standard my wife and I could view the medical scans on the CDs we were given.  As it is, the best use for those CDs is as coffee mats or perhaps Frisbees.

I'm asking that you pursue making legislation which requires the NHS to exchange data in standard formats or to have the NHS (or a delegated standards body) devise and evolve such formats where standards don't exist or don't meet current needs.

I'm also asking that you resist any moves to let the NHS build software systems.  They are clearly rubbish at doing it.

Yours sincerely,
   Bruce Badger

Saturday, June 02, 2012

Testing through the seasons

Just fixed a bug in the PostgreSQL drivers EXDI test suite which only happened when daylight savings kicked in.  The failing test was a fairly new one put in place to exercise how timestamps with time-zones are handled and it's been working fine through the winter ... but with BST, it was not so good.

All fixed now in the latest version available from the public Store.

Sunday, October 09, 2011

Wow - the new VMWare fusion 4.0 UI is such a load of rubbish

VMWare is just about the only software product I pay for. Everything else is either open source or comes with a device.

Anyhow, I just upgraded my copy of VMWare fusion (the mac host package) from version 3.x to version 4.x and boy is the UI rubbish. VMWare have added all kinds of cool UI gizmos to their utility screens (the stuff used to manage VMs before you even start them) but in the process have made the UI painfully slow and clunky.

With version 3.x I could see all my VMs in a single window and click on any of them and see the configuration on a pane to the right. The configuration pane presented summary information including notes I left to myself about the intended use of the VM, and on that same pane I could drill down to specific details such as network, disk or memory configuration. All the VMs remained listed to the left.

With 4.0 a cool slidy single-pane UI opens showing a black rectangle for each VM (which could show a screen snapshot from a running VM - cool, but is useless to me because I only save my VMs in a shut down state). Only the short name of each VM is shown beneath each black rectangle. No sign of my comments nor a summary of the VM configuration. If I click on a rectangle the VM might start, or the rectangle might just be selected depending on where I click on the rectangle (the faint grey arrow in the middle is a control(!) not just part of the image). If the VM decides to start, my list of VMs is removed (I didn't ask for that!) and the VM boots in it's own window. To get back to the admin window I need to go to the VMWare application menu or recall a special three-key incantation. If the VM doesn't start I just get the name of the VM highlighted in blue and then I have to press a button elsewhere on the admin window to see the config summary, and even then I just get a (very flashily displayed) set of icons, again replacing my list of VMs, oh, and the window leaps to a different part of the screen for some reason. Only when I click on the 'General' icon do I see the comment I left for myself. Then, having found that I had not selected the VM I wanted I close the settings icon panel and ... just get a big black rectangle for that one VM. To get back to my list of VMs I need to use the three-finger incantation again *and* have to close the VM I didn't want because that now hangs around in a window of it's own.

In short (well, fairly short) the move from the 3.x admin UI to 4.0 means instead of one click to understand the nature of a VM and then one click to understand another VM I have: click to select a rectangle (careful not to click the middle!), then press a button in the top left of the UI, then press the General icon ... then to see the next VM I have to {shift}+{cmd}+L, close the window for the VM I'm not interested in and ... start all over again. Not only are there many, many more steps but each step is sloooowwwww.

The VMWare fusion 4.0 admin UI is a massive leap backwards in terms of usability. It's crap when compare to the 3.x admin UI. It's like a graphic artist or widget designer was let loose without an experienced UX person there to guide them.

Dear VMWare, for fusion 4.1 could you please throw away the rubbish cheap shiny 4.0 admin UI and go back to the 3.x model. The 3.x UI may not have been so cool, but it worked much, much, better. Thanks.

Saturday, October 08, 2011

BBC News - Millions stroll in New York's 'park in the sky'

It's great to see the people in New York enjoying being able to walk above the streets:

BBC News - Millions stroll in New York's 'park in the sky'

The high walks in the City of London provide a similar escape from the dirty traffic filled streets. It's unfortunate that here in London the high walks are being systematically closed and demolished at the hands of the City of London chief planning officer, Peter Rees. I attended a planning meeting where he seemed to take enormous pleasure in supporting a project which depletes the high walk even more. He joked about the people who use the high walks in a most demeaning way.

Perhaps he should have a look at how New York is recognising the value of pedestrian spaces away from traffic, and look to projects which improve rather than diminish the lived-in environment.

Wednesday, July 27, 2011

Who looks at Smalltalk?

The C guys looked at Smalltalk and said they didn't need object orientation. They could structure their programs just fine.

The C++ guys looked at Smalltalk and thought, actually, the OO stuff is rather cool for building well structured code, but all the rest is just a performance hog, especially garbage collection.

The Java (and later C#) guys looked at Smalltalk and thought, you know, in most cases garbage collection is a really good thing as it saves programmers time and completely avoids common C/C++ malloc/free bugs, and anyway the performance cost is hardly noticeable in most applications, but all the rest of the stuff in Smalltalk is fluff, especially dynamic typing because it's obvious that static type checking will result in much less buggy programs, especially when you use JUnit as well.

The Python and Ruby guys looked at Smalltalk and realised that using dynamic types gave them much less brittle systems which could flexibly change and evolve over time. They liked JUnit too, but called theirs something else, and the ideas of refactoring (that was invented by the Java guys too, right?) were even more powerful in a dynamically typed world ... and if Smalltalk is so good why didn't the Smalltalk people think of something like JUnit and refactoring! All the other stuff in Smalltalk was just fluff, though. For example, who would want to have an image based development environment or have the development tools themselves visible and changeable in that same development environment?

Anyone?

Saturday, July 16, 2011

Fix My Street

The BBC have promoted a council run service for reporting street cleaning issues. All well and good, but FixMyStreet has been running for longer and is independent of the person reporting the problem and, critically, the council responsible for fixing the problem. There is very definitely a conflict of interests with the council running the site which is watching the council.

I really wish the council in the BBC story had put the money towards helping to improve FixMyStreet, or just promoting it ... or even just improving their response to issues raised through FixMyStreet.

Thursday, May 05, 2011

Yes to AV?

In the UK today we get to vote in a referendum on whenther AV should be adopted in place of first past the post in elections for MPs.

I thought of two situations where AV would be useful to me.
  • Where an incumbant MP I like is replaced by their party. If I still like the policies of the party I would wish to say that I'd rather keep the current MP, but if not then I'll go with the person the party now nominates. With AV I can do this.
  • Similar to the above, if I would like to see a person not aligned with a party to be the MP, but if that is not possible then have the party I feel is 'safe'. Again AV lets me do this.
They key is I can submit more information with my single vote using AV.

Some have suggested that AV is a poor compromise and that we should really be aiming to have PR, but I disagree strongly with that. I very much want to retain directly elected MPs who represent specific areas rather than moving to the PR model where I would choose a party and the party would pick the MP(s) who represent me.

As for the information-free mud slinging we have seen by the major parties leading up to this referendum, well, I think we'd be better off just ignoring that.

So, AV seems to let me say more in my single vote while still ending up with a single MP to represent my area in parliament. One person, one vote, one MP. I think I like that.

Tuesday, March 08, 2011

Flext9 asks too much>

The Register think Flext9 is a great keyboard for an Andorid phone:

Nuance Flext9 • reghardware

It costs £3, which seems OK to me. What is not so OK is that this keyboard app wants to granted permission to "Read phone state and Identity" and have "Full Internet access".

I've taken to removing apps which ask for that combination unless they clearly need it. I don't understand why a keyboard app would need to pull my identity from the phone and then be able to send it over the Internet.

Three quid is fine, but I think they ask for too much else