Why are globals set to tls by default? and why is fast code ugly by default?
ryuukk_
ryuukk.dev at gmail.com
Sun Mar 26 20:41:44 UTC 2023
On Sunday, 26 March 2023 at 19:08:32 UTC, Steven Schveighoffer
wrote:
> On 3/26/23 2:07 PM, ryuukk_ wrote:
>> Hi,
>>
>> It's common knowledge that accessing tls global is slow
>> http://david-grs.github.io/tls_performance_overhead_cost_linux/
>>
>> What i do not understand is the reasoning behind choosing tls
>> global by default in D
>
> If you know a variable is not `shared`, then you know it can
> only be accessed from the current thread. This has huge
> implications for thread access.
>
> However, one problem that D has no good solution is passing
> thread-local data to another thread (to be owned by the new
> thread, and no access in the current thread). That's typically
> the most common use case for "shared data".
>
> -Steve
I haven't explored this use case, that must explain why i find it
surprising, however, i read about other languages too, and they
seem to be explicit whenever they make use of TLS
C, C++, Rust, Zig, Go doesn't do TLS by default for example
More information about the Digitalmars-d-learn
mailing list