Performance optimization (allocation inside a for loop)
Andreas Romeyke
romeyke at cbs.mpg.de
Thu Apr 2 01:11:25 CDT 2009
Hello,
Am Thu, 2 Apr 2009 00:18:28 +0100
schrieb r <nbs.public at gmail.com>:
> A common strategy is to allocate a bit more space than currently
> needed, so that malloc/realloc doesn't need to be called every single
> time the user appends data to the structure. Even better, this margin
> can be made dependent on the current structure size (e.g. proportional
> to n or to log(n)). This second scheme results in better
> performance/memory occupation ratio.
You are right, BUT octave handles with really big amounts of data. A
pre-allocation of data is not helpful in this cases.
> I'm (now) perfectly OK with preallocating memory manually, but it took
> me a lot of time to figure out where the bottleneck is. BTW, low "for"
> loop performance is commonly blamed on the lack of a JIT compiler, but
> I wouldn't be surprised if at least some of the test cases were
> actually suffering from issues like memory allocation. After all, JIT
> compilers don't typically speed up evaluation by more than a constant
The better way is to improve the tools to support the developers and
users to find bottlenecks, to suggest good practises and to develop an
JIT-compiler.
my 2 cents...
Bye Andreas
--
Software Developer / Dipl. Inform. (FH)
Max Planck Institute for Human Cognitive and Brain Sciences
Department of Psychology
Stephanstr. 1a, 04103 Leipzig, Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/help-octave/attachments/20090402/ccef3009/attachment.bin
More information about the Help-octave
mailing list