Efficient thread-local shared variables

ncellier at ifrance.com ncellier at ifrance.com
Tue Oct 24 07:39:31 UTC 2006


Hi Klaus and Andreas
I find the local shared variable feature most useful.
I'am trying to understand your suggestions, sorry for being slow-brained...

Andreas:
- have a SharedPool per process, compiler does replace symbolic name with integer indices
 pseudo-code for PerProcessThing:
 Processor activeProcess sharedPool at: PerProcessThingCompiledIndex
- have to recompile code when an entry removed from sharedPool
 (efficiency rely on this event being rare like for instance variables)

Klaus:
- have a single SharedPool with values being an array, and an index per process?
  pseudo code for PerProcessThing:
  PerProcessThing localSharedValue
  where localSharedValue is (^self at: Processor activeProcess processIndex)
- have to reset all the shared value arrays each time a process is created or die...

I am not sure i understood well Klaus proposition
Did i get it ?

Nicolas

Le Mardi 24 Octobre 2006 07:33, Klaus D. Witzel a écrit :
> Hi Andreas,
>
> on Tue, 24 Oct 2006 06:46:26 +0200, you wrote:
> > Folks -
> >
> > For a variety of reasons I am in dire need of the ability to vector
> > shared variables (globals, class vars and pool vars) through an extra
> > indirection vector per process (really per island but binding per
> > process seems to be simpler for now). Since I need this for *each and
> > every shared variable* it needs to be *very* efficient.
> >
> > The question is: What is the most efficient way to implement such a
> > scheme?
>
> The fastest indirect access is through literal variables (limited only by
> the # of literals allowed per method).
>
> Since you are willing to spend a #symbol per variable, formally declare a
> "descriptor" to be a class var (or use a pool). Take #PerProcessThing as
> as example; initialize PerProcessThing to a subinstance of Association
> which holds a fast and fixed Array index.
>
> Then all you need in the scope of activeProcess is a shared Array which is
> indexed by the above machinery. Example use:
>
> 	PerProcessThing localSharedValue
> 	PerProcessThing localSharedValue: somethingElse
>
> Not counting "Processor activeProcess scope", the above is the fastest
> double-indirect access that I can think of.
>
> /Klaus



________________________________________________________________________
iFRANCE, exprimez-vous !
http://web.ifrance.com


More information about the Squeak-dev mailing list