POV-Ray : Newsgroups : povray.off-topic : Still random : FIXED! Server Time
29 Sep 2024 19:24:11 EDT (-0400)
  FIXED!  
From: Invisible
Date: 8 May 2009 08:59:27
Message: <4a042caf$1@news.povray.org>
Invisible wrote:

> PS. I still need to fix the rendering program. I wrote it while at work, 
> and it worked OK, but was rather inflexible and brittle. So when I got 
> home, I wrote it again. But for some reason, the version I wrote at home 
> is about 10x slower - and I can't figure out why! o_O

I just spent about 2 hours peering over the source code for the two 
programs, back to back, side by side. Considering that they were written 
on different ways on different computers, it's remarkable how many of 
the files are identical character-by-character. (Most of them differ by 
variable names, function names, order of arguments, etc.)

I even tried replacing source files from the defective version with 
files from the optimal version, but to no avail. The program is big, but 
not *that* damned big! There's only so many places to look for bugs...

I tried everything I could think of to fix the problem. *Finally*, I 
discovered that replacing one block of code with an apparently 
equivilent block causes a 10x speedup. Whiskey Tango Foxtrot?

At least, I know the bug is inside one tiny function. But where?

Well, I just nailed it. It was in the adaptive subsampling code. When 
computing the error in the current step, I wrote

   error = mag (position1 - position3) + mag (velocity1 - position3)

Looks fine, right?

...until you put it on consecutive lines:

   errorP = mag (position1 - position3)
   errorV = mag (velocity1 - position3)

PWN3D!

Change the second line to

   errorV = mag (velocity1 - velocity3)

and suddenly the program speeds up massively.

D'OH!! >_<


Post a reply to this message

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