More threads -> Slower program ??
Yuxuan Shui via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 12 16:23:02 PDT 2015
On Wednesday, 12 August 2015 at 23:15:48 UTC, Adam D. Ruppe wrote:
> On Wednesday, 12 August 2015 at 23:06:32 UTC, Yuxuan Shui wrote:
>> What is wrong here?
>
> I didn't look too closely, but there's some memory allocations
> going on there which have the potential of locking all the
> threads any time one of them tries to allocate.
>
> Parallelism's benefits are largely erased by the memory
> allocator lock and can be set back by the cache being
> invalidated as it jumps around that allocated memory, so you
> generally want to make sure the threads are doing work on local
> variables only.
>
> This restricts what you can do with strings, since most the
> std.string functions allocate new strings for their return
> values...
Is there a way to do thread-local allocations?
More information about the Digitalmars-d-learn
mailing list