Dan Sugalski wrote:

At 5:24 PM -0500 1/22/04, Deven T. Corzine wrote:

Damian's issues were addressed before he brought them up, though not in one spot.

A single global lock, like python and ruby use, kill any hope of SMP-ability.

Hand-rolled threading has unpleasant complexity issues, is a big pain, and terribly limiting. And kills any hope of SMP-ability.

What about the single-CPU case? If it can really take 4 SMP CPUs with locking to match the speed of 1 CPU without locking, as mentioned, perhaps it would be better to support one approach for single-CPU systems (or applications that are happy to be confined to one CPU), and a different approach for big SMP systems?


Corruption-resistent data structures without locking just don't exist.

The most novel approach I've seen is the one taken by Project UDI (Uniform Driver Interface). Their focus is on portable device drivers, so I don't know if this idea could work in the Parrot context, but the approach they take is to have the driver execute in "regions". Each driver needs to have at least one region, and it can create more if it wants better parallelism. All driver code executes "inside" a region, but the driver does no locking or synchronization at all. Instead, the environment on the operating-system side of the UDI interface handles such issues. UDI is designed to ensure that only one driver instance can ever be executing inside a region at any given moment, and the mechanism it uses is entirely up to the environment, and can be changed without touching the driver code.


This white paper has a good technical overview (the discussion of regions starts on page 9):

http://www.projectudi.org/Docs/pdf/UDI_tech_white_paper.pdf

I'm told that real-world experience with UDI has shown performance is quite good, even when layered over existing native drivers. The interesting thing is that a UDI driver could run just as easily on a single-tasking, single-CPU system (like DOS) or a multi-tasking SMP system equally well, and without touching the driver code. It doesn't have to know or care if it's an SMP system or not, although it does have to create multiple regions to actually be able benefit from SMP. (Of course, even with single-region drivers, multiple instances of the same driver could benefit from SMP, since each instance could run on a different CPU.)

I don't know if it would be possible to do anything like this with Parrot, but it might be interesting to consider...

Deven

Reply via email to