Thread-local storage and Performance

Denis Koroskin 2korden at gmail.com
Mon Oct 26 08:34:56 PDT 2009


On Mon, 26 Oct 2009 18:26:02 +0300, Pelle Månsson  
<pelle.mansson at gmail.com> wrote:

> dsimcha wrote:
>> Has D's builtin TLS been optimized in the past 6 months to year?  I had
>> benchmarked it awhile back when optimizing some code that I wrote and
>> discovered it was significantly slower than regular globals (the kind  
>> that are
>> now __gshared).  Now, at least on Windows, it seems that there is no
>> discernible difference and if anything, TLS is slightly faster than  
>> __gshared.
>>  What's changed?
>
> I was under the impression that TLS should be faster due to absence of  
> synchronization.

__gshared doesn't have any locks/barriers associated with them.
TLS should be slightly slower due to an additional indirection, but I  
don't think it would be noticeable.



More information about the Digitalmars-d mailing list