D semantics, shared as a heap storage specifier
Etienne Cimon via Digitalmars-d
digitalmars-d at puremagic.com
Sat Dec 6 09:35:38 PST 2014
This is the only issue preventing a truly thread-local GC for better
multi-core scalability for D applications. From:
https://github.com/D-Programming-Language/druntime/pull/1057#issuecomment-65904128
The best way to achieve a thread-local GC would be to improve and
enforce `shared`-correctness in Phobos/druntime (at first). We need to
start considering `shared` as a heap storage attribute as well, for
consistency. An optional compiler warning (through a flag) would be a
start.
If even a 30% speedup is possible down the line, it's worth it. The more
threads, the more improvements.
There's also some new opportunities with this. Here's an example that
involves TLS data to influence the behavior of shared objects, without
using a global `T[Thread]` hashmap.
```D
shared class A {
private bool m_init; // different on every thread
public shared:
AA m_impl;
synchronized void init() {
if (!m_init)
m_impl.add(Thread.getThis());
}
...
}
```
More information about the Digitalmars-d
mailing list