Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
July 18, 2014 mysterious performance gain | ||||
---|---|---|---|---|
| ||||
Hello, So I have this big, performance critical function that takes about 9 seconds to execute. If I add : double[] direct = new double[2]; ... at the beggining of the function, with no further reference to this array, suddenly it takes only 8 seconds. Any rational explaination to this? ( Seems unrelated to garbage collection ) |
July 18, 2014 Re: mysterious performance gain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Archibald | Archibald:
> Any rational explaination to this? ( Seems unrelated to garbage collection )
Not nearly enough info to answer. It looks fishy.
Bye,
bearophile
|
July 18, 2014 Re: mysterious performance gain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Archibald | On Friday, 18 July 2014 at 13:21:09 UTC, Archibald wrote:
> Hello,
> So I have this big, performance critical function that takes about 9 seconds to execute. If I add :
>
> double[] direct = new double[2];
>
> ... at the beggining of the function, with no further reference to this array, suddenly it takes only 8 seconds.
>
> Any rational explaination to this? ( Seems unrelated to garbage collection )
Which compiler? Which compiler flags? how are you benchmarking it?
|
July 18, 2014 Re: mysterious performance gain | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | On Friday, 18 July 2014 at 15:55:29 UTC, John Colvin wrote:
> On Friday, 18 July 2014 at 13:21:09 UTC, Archibald wrote:
>> Hello,
>> So I have this big, performance critical function that takes about 9 seconds to execute. If I add :
>>
>> double[] direct = new double[2];
>>
>> ... at the beggining of the function, with no further reference to this array, suddenly it takes only 8 seconds.
>>
>> Any rational explaination to this? ( Seems unrelated to garbage collection )
>
> Which compiler? Which compiler flags? how are you benchmarking it?
dmd 2.065 , -O and using std.datetime.StopWatch before and after function call.
I tried to narrow down the "problem" but doesn't look easy.
I guess never mind that.
|
July 18, 2014 Re: mysterious performance gain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Archibald | On 07/18/2014 06:21 AM, Archibald wrote: > So I have this big, performance critical function that takes about 9 > seconds to execute. If I add : > > double[] direct = new double[2]; > > ... at the beggining of the function, with no further reference to this > array, suddenly it takes only 8 seconds. Here is a wild guess: There is some undefined behavior because you are accessing locations on the stack that don't belong to you. When you introduce 'direct', it shifts the contents of the stack and the bytes that are used unintentionally are now different, which change the way the loop behaves. Ali |
July 18, 2014 Re: mysterious performance gain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Archibald | On Friday, 18 July 2014 at 13:21:09 UTC, Archibald wrote:
> Hello,
> So I have this big, performance critical function that takes about 9 seconds to execute. If I add :
>
> double[] direct = new double[2];
>
> ... at the beggining of the function, with no further reference to this array, suddenly it takes only 8 seconds.
>
> Any rational explaination to this? ( Seems unrelated to garbage collection )
Perhaps some function your critical code calls might require memory to be aligned to a particular offset (say 16 byte). What made you think of adding the unused array?
|
Copyright © 1999-2021 by the D Language Foundation