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 18:07:03 UTC 2023


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

What i find even more weird is writing fast code is ugly in D

Look at this ugly code

```D
__gshared int fast_code_ugly;
```

It should be the opposite

Slow code ugly
Fast code beautiful

What can be done about it?

Renaming ``__gshared``

``shared`` is even more ugly since everything must be shared 
afterwards

I would have prefered if i had to manually set things to tls

```D
@tls int slow_code_ugly;
```

Even C does it better: 
https://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html




More information about the Digitalmars-d-learn mailing list