Final by default?

Steven Schveighoffer schveiguy at yahoo.com
Fri Mar 14 06:41:07 PDT 2014


On Fri, 14 Mar 2014 05:35:03 -0400, Don <x at nospam.com> wrote:

> On Thursday, 13 March 2014 at 13:47:13 UTC, Steven Schveighoffer wrote:
>> On Thu, 13 Mar 2014 09:37:51 -0400, Dicebot <public at dicebot.lv> wrote:
>>
>>> On Thursday, 13 March 2014 at 13:16:54 UTC, Daniel Murphy wrote:
>>>> "Steven Schveighoffer"  wrote in message  
>>>> news:op.xcnu55j2eav7ka at stevens-macbook-pro.local...
>>>>
>>>>> > The worst breaking change in D2, by far, is the prevention
>>>>> > > of
>>>>> array stomping.
>>>>>
>>>>> What is your use case(s), might I ask? Prevention of array stomping,  
>>>>> I thought, had a net positive effect on performance, because it no  
>>>>> longer has to lock the GC for thread-local appends.
>>>>
>>>> I would guess they're setting length to zero and appending to re-use  
>>>> the memory.
>>>
>>> Exactly. So far looks like upon transition to D2 almost all arrays  
>>> used in our code will need to be replaced with some variation of  
>>> Appender!T
>>
>> I think you might find that it will run considerably faster in that  
>> case. In the old mechanism of D1, the GC lock was used on every append,  
>> and if you had multiple threads appending simultaneously, they were  
>> contending with the single element cache to look up block info.  
>> Appender only needs to look up GC block info when it needs more memory  
>> from the GC.
>
> We don't use threads.

In that case, the GC will not use a lock (I think it avoids allocating a  
lock until at least 2 threads exist). However, you can still benefit from  
the expanded cache if you are appending to 2 to 8 arrays simultaneously.  
The D1 cache was for one block only.

-Steve


More information about the Digitalmars-d mailing list