Efficient thread-local shared variables

Klaus D. Witzel klaus.witzel at cobss.com
Tue Oct 24 17:17:29 UTC 2006


Hi Reinout,

on Tue, 24 Oct 2006 18:44:49 +0200, you wrote:
> Klaus wrote:
>>
>> I don't know why but the discussion with you "inspired" three new  
>> operations for my implementation:
>>
>> - specialization, clones the anonymous class (shares the method  
>> dictionary)
>> - proliferation of name space, locally copies the method dictionary  
>> ("rapidly" doubles it, still shares methods, variables and state)
>
> I presume you want to do above at Process creation time, and

Yes, e.g. at "schema creation" time.

>> - proliferation of state, locally clones "un-shares" a variable (and so  
>> its state)
>
> on global var assignment.

Yes, e.g. at "schema evolution" time.

>
> Another approach could be to (ab)use SearchOrder. Assuming you still  
> have something like a 'global or 'default' scope you can put that at the  
> bottom of your SearchOrder and have a per-thread Vocabulary (perhaps  
> with scoping support) at the top of the SearchOrder.
>
> So at process creation time you only need to create an *empty*  
> Vocabulary for each scope and chain it to the global SearchOrder,  
> reading a global var will now fall through to the global definitions  
> while assigning a new value to that var will put it in the topmost  
> Vocabulary masking the global state of that variable.

:)

> Thinking this through even further: you could defer the creation of the  
> thread-local Vocabularies in the SearchOrder until the first write is  
> done, if the code only does reads the Process creation overhead can be  
> pretty close to zero :-)
>

Thank you for sharing the ideas!

/Klaus

>
> R
> -
>




More information about the Squeak-dev mailing list