[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Performance optimization (allocation inside a for loop)
From: |
Jaroslav Hajek |
Subject: |
Re: Performance optimization (allocation inside a for loop) |
Date: |
Wed, 8 Apr 2009 07:16:24 +0200 |
On Tue, Apr 7, 2009 at 3:48 PM, Francesco Potorti` <address@hidden> wrote:
>>I gave the idea a second thought - maybe it has some merits. Sometimes
>>you really want to use an array as a stack in Octave to avoid going
>>through a loop twice, so Octave can try to optimize such usage.
>
> Two thoughts only:
>
> 1) if stack operations are one target of this optimisation, then it
> would better to have a hysteresis behaviour, that is, deallocate
> one chunk only when the free space is 2*chunk big; more generally,
> deallocate so that at least a whole unused chunk remains unused
Currently, the behaviour is that pop *never* reallocates. I think it
is not necessary, given the automatic stripping of over-allocated
portion when the array is being manipulated as whole.
> 2) 1kB for chunk size is very little today. I would have considered
> one memory page size at least, but since marginal improvements are
> smaller for big chunks, maybe the current choice is good. Only a
> benchmark can tell, I suppose.
>
No problem. Feel free to do any benchmarks and suggest a better size
or even a better strategy. 1024 (i.e. 8kB for a double array) should
cut the amount of reallocations down by a factor 1000, so it seemed
enough to me.
There is still the possibility of making this chunk size configurable,
I only didn't do it because we already have hardwired help buffer
sizes elsewhere (blocked transpose, sorting).
regards
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- Re: Performance optimization (allocation inside a for loop), (continued)
- Re: Performance optimization (allocation inside a for loop), Francesco Potorti`, 2009/04/02
- Re: Performance optimization (allocation inside a for loop), r, 2009/04/02
- Re: Performance optimization (allocation inside a for loop), John W. Eaton, 2009/04/02
- Re: Performance optimization (allocation inside a for loop), r, 2009/04/02
- Re: Performance optimization (allocation inside a for loop), Jaroslav Hajek, 2009/04/04
- Re: Performance optimization (allocation inside a for loop), r, 2009/04/04
- Re: Performance optimization (allocation inside a for loop), Jaroslav Hajek, 2009/04/04
- Re: Performance optimization (allocation inside a for loop), Jaroslav Hajek, 2009/04/04
- Re: Performance optimization (allocation inside a for loop), Jaroslav Hajek, 2009/04/07
- Re: Performance optimization (allocation inside a for loop), Francesco Potorti`, 2009/04/07
- Re: Performance optimization (allocation inside a for loop),
Jaroslav Hajek <=
- Re: Performance optimization (allocation inside a for loop), Francesco Potorti`, 2009/04/08
- Re: Performance optimization (allocation inside a for loop), Jaroslav Hajek, 2009/04/03