[gambit-list] Native threading with C++?

Marc Feeley feeley at iro.umontreal.ca
Wed Mar 28 09:26:22 EDT 2012


On 2012-03-28, at 8:59 AM, Mikael wrote:

> Dear Marc, I'm curious,
> 
> Den 22 mars 2012 14:46 skrev Marc Feeley <feeley at iro.umontreal.ca>:
> 
> That's not currently possible because the Scheme global variables, and some global state of the Gambit VM, are implemented using global C/C++ structures.  What is needed (and something that is on my TODO) is to allow instances of this state to be created dynamically (essentially a constructor for the Gambit VM).  That way several instances of Gambit can coexist in the same OS process.
>  
> Unfortunately, this will slow down accesses to global variables, because an indirection will be needed.
> 
> So with this several-gambit-vm:s-coexisting-in-the-same-os-process option, each read and write to a global var will require one more indirection and that's it?

The "indirection" might be more than a pointer indirection.  The point is that each instance of the VM will have its own set of global variables.  I think it can be implemented with a single indirection by declaring that all the VMs have the same set of global variables (but each instance of a global variable has its own value).  But I haven't implemented this yet.

> Does access to Gambit runtime procedures like |list| and |open-string| qualify as this?

Yes.  Even if it is very likely that all the instances contain the same value.

> You mean one indirection i.e. just following one pointer once right? If so I suppose this gives a max approx 0.5% performance decrease for typical code - if so, for when this functionality is needed, it's really worth it.

Only by benchmarking this will I be able to tell if it is 0.5% or 5%.  It could be 50% for some programs constantly accessing global variables.

> Will there be a configure argument to disable/enable this option both now, and later when running in SMP mode?

Absolutely.  Gambit's architecture, with the gambit.h header file, makes it easy to have a switch to enable the existence of multiple VM instances.  When this is disabled, I expect the same performance as now.

Marc




More information about the Gambit-list mailing list