Monday, June 11, 2007
While reading through the WorkerPool API, its model of code and data isolation (i.e. processes + messages, not threads + shared memory) reminded me of similar models of inter-process coordination in Erlang and QNX.
It also made me think of a cool example written for QNX, many moons ago, by the late Dan Hildebrand, which was a distributed Mandelbrot generator. A UI/administrator task would farm out work (columns in the Mandelbrot set) to different worker tasks, possibly running on different machines. As each worker sent in its result, the UI would draw the column, and respond with more work for the worker. It was a cool example, and looked cool too: due to different machines running at different speeds, you would see the results kind of shimmer in, with faster machines generating the leading edge, and slower machines trailing and filling in the blanks (Dan also designed it so the faster machines would take over from the slower ones if there was nothing else to do).
To run it, click the link below. The first time, Google Gears will ask you to grant permission to this app. Press the Start button to start it. You can also use the controls at top left to zoom in/out and pan around (note that the number of iteration for each point is low, so it gets fuzzy fast as you zoom in).
Important: I've only tested this in Firefox 184.108.40.206. It requires the Canvas tag, so it will not work in IE6 or earlier (not sure if IE7 has Canvas).
Note that the UI stays live: while it's computing, you can click the Toggle Background button to simulate interaction with the UI.
Compare this to a similar example not using Gears, in which the UI goes completely dead until the computation is done.
I think Google Gears is an important addition to the Google platform, and beyond, since it's distributed under a liberal BSD license and not restricted for use by Google.
In addition to enabling a whole new class of offline-enabled web-apps, I think its WorkerPool support may popularize some interesting (though not new) models of parallel and distributed computation. It will be interesting to see how Google Gears develops. For example, what would happen if they provided a factory for creating worker pools back on the Google grid? There's nothing preventing this in the current API.
One final note: if you refresh the page multiple times, it will eventually run out of worker threads and may cause your browser to crash. From what I can tell, this appears to be a bug in the Google Gears implementation.