POV-Ray : Newsgroups : povray.unofficial.patches : Why does POV-Ray allocate so many memory blocks for textures? : Re: Why does POV-Ray allocate so many memory blocks for textures? Server Time
28 Sep 2024 16:42:31 EDT (-0400)
  Re: Why does POV-Ray allocate so many memory blocks for textures?  
From: Thorsten Froehlich
Date: 9 Jun 2003 08:27:31
Message: <3ee47d33$1@news.povray.org>
In article <3ee40ca7@news.povray.org> , "Ray Gardener" 
<ray### [at] daylongraphicscom> wrote:

> I asked this before but no one explained it fully.
> Mr. Froehlich mentioned something about Knuth,
> numerous potential texture accesses during raytracing,
> and implied that the answer should be patently obvious.

Per image you have, using common allocators (which use one native-size
pointer), plus one pointer for each color component, makes two pointers per
color component, and thus six pointers per line plus a pointer for the not
used transparency.  This is 28 bytes (32 bytes with transparency) per line,
regardless of the line width.  For a line that is only 256 pixels width, and
has no transparency, you get about 3.65% memory overhead, for a 1024 pixel
width image with transparency you get 0.78% memory overhead.

In the old days, such fine-grain access would indeed be faster as memory
access required no operations on the x-coordinate index (compared to
additions or even multiplications using more general access).  Today, this
does no longer matter.  But the space "wasted" by this kind of allocation
today no longer matters either.

There is a lot that can be optimised in POV-Ray, you should start where it
makes the most sense.  This requires profiling the code, and then to
optimise those spots.  Not to arbitrarily pick some segment of code and
optimise it, potentially introducing new bugs and gain, well, nothing at
all.

As Knuth really has shown over and over in his books, you first look for a
better algorithm, then you optimise that algorithm, not the other way
around.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.