[phobos] Parallelism in Phobos

Sean Kelly sean at invisibleduck.org
Fri Aug 27 07:54:47 PDT 2010


I've heard that LOCK INC is actually slower than a CAS loop, but have no data to back this up.  What I really don't like about INC however is that it doesn't put the new value of the incremented variable in a register, so there's no way of returning the new value.

On Aug 27, 2010, at 7:45 AM, David Simcha wrote:

> IIRC (maybe this has changed recently) atomic increments in core.atomic are based on CAS instructions in a while loop, which is how more generic lock free primitives are made.  Atomic increment should be special cased to directly use lock; inc [someRegister];.  
> 
> On Fri, Aug 27, 2010 at 10:40 AM, Sean Kelly <sean at invisibleduck.org> wrote:
> On Aug 27, 2010, at 7:11 AM, David Simcha wrote:
> >
> >>
> >> I see you have some CAS instructions. Sean, I think it's a good time to collaborate with David to put them into druntime or std.concurrency.
> >
> > Yeah, D needs a real atomics library.  core.atomic is a good start, but I won't use it until it can efficiently do things like atomic increment.
> 
> How could it be made more efficient?
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
> 
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos



More information about the phobos mailing list