[Bench!][Mir] +54%..+185% performance boost for Mersenne Twister.

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 28 08:33:38 PST 2016


On 11/27/16 8:58 AM, Guillaume Piolat wrote:
> On Sunday, 27 November 2016 at 13:35:48 UTC, Andrei Alexandrescu wrote:
>>
>>> A useful intermediate step is to have these "[shared] static this" ctor
>>> call a function instead, so that programs without druntime can call them
>>> too.
>>
>> That would be progress.
>>
>
> Same story for core.cpuid which is initialized by a shared static
> constructor.
> https://github.com/dlang/druntime/blob/master/src/core/cpuid.d
>
> It seems the "shared static this" is allowed to break immutable but a
> function wouldn't. So maybe the variables here should be private
> __gshared?.

How we do a similar thing for core.time:

https://github.com/dlang/druntime/blob/master/src/core/time.d#L2388

This function is called from the druntime startup (before any static ctors).

Not sure if it helps or not.

Note that we can cheat the type system here because we know that nothing 
else will access the data before it's initialized. There is also a check 
in the function to ensure it's only done once.

-Steve


More information about the Digitalmars-d mailing list