Minimalistic Software Transactional Memory

Michael Sparks ms at cerenity.org
Sun Dec 9 09:54:31 EST 2007


Duncan Booth wrote:

> Michael Sparks <ms at cerenity.org> wrote:
> 
>> I'm interested in writing a simple, minimalistic, non persistent (at
>> this stage) software transactional memory (STM) module. The idea being
>> it should be possible to write such a beast in a way that can be made
>> threadsafe fair easily.
>> 
>> For those who don't know, STM is a really fancy way of saying
>> variables with version control (as far as I can tell :-) designed to
>> enable threadsafe shared data.
>> 
>> I'm starting with the caveat here that the following code is almost
>> certainly not threadsafe (not put any real thought into that as yet),
>> and I'm interested in any feedback on the following:
>> 
>> * Does the API look simple enough?
>> * Are there any glaring mistakes in the code ? (It's always harder
>> to see
>> your own bugs)
>> * What key areas appear least threadsafe, and any general
>> suggestions
>> around that.
>> 
>> If I get no feedback I hope this is of interest. Since these things
>> get archived, if you're reading this a month, 6 months, a year or more
>> from now, I'll still be interested in feedback...
> 
> Unless you really are desperate to reinvent the wheel, have you looked at
> ZODB? https://launchpad.net/zodb
> 
> ZODB gives you the transactional model you want. It also gives you
> persistence, but if you don't want that you can simply connect to a non-
> persistent store.

That seems somewhat overkill for my needs. ZODB's distribution is 3.3MB in
size, whereas the system I want a minimalistic, non-persistant[1]
transactional memory for is 345K in size. (The Axon part of kamaelia)
I'll take a look though.

[1] I said "at this stage" because its something I *may* want in future
    for some possible usecases, but generally I'm not really very interested
    in persistence. (At least not where I'm putting this :-)

Context: I want thing that use the following class threadsafe, and can think
of a few ways of doing this, and STM seems one of the more "nicer" ways of
doing so. (it's clients are currently just generators which makes it safe at
the moment)

https://kamaelia.svn.sourceforge.net/svnroot/kamaelia/branches/private_MPS_Scratch/Axon/Axon/CoordinatingAssistantTracker.py

It's used to provide an ENVironment like facility (similar to os.environ)
for generator based Kamaelia components.

Thanks for the feedback :-)


Michael.





More information about the Python-list mailing list