POV-Ray : Newsgroups : povray.off-topic : Optimizations... : Re: Optimizations... Server Time
5 Sep 2024 17:12:02 EDT (-0400)
  Re: Optimizations...  
From: Patrick Elliott
Date: 23 Jul 2009 17:18:04
Message: <4a68d38c@news.povray.org>
Invisible wrote:
> Oh, sure, I understand *why* this happens. But it is very, very 
> disturbing to realise that just doing the same instructions in a 
> different order, or storing the same data in a different order, can have 
> such a vast effect on performance. It seems we have reached an age where 
> the complexity class of an algorithm is almost irrelevant, and the only 
> important property is the specific low-level details of exactly how the 
> algorithm has been implemented on a specific hardware platform.
> 
> This is the antithesis of high-level programming.
> 

Was an example if this I saw recently with multi-core programming. If 
you changed the memory "directly" which was used between multiple 
threads in the program, then all cores would have to wait for the 
"current" core to finish handling the data, thus unlocking the memory, 
so that the other cores would operate. The result would be that every 
single core would be wobbling between wait and active, and your speed 
would drop *under* that of a single core working on the same process. 
The fix was simple. Make your function so you pass the value (not a 
pointer), handle it internally as a temporary variable, then return it, 
where the calling function would only set the value. The memory would be 
free while the function was being called and executing, and only "lock" 
during the brief moment the final value was set. Result - the expected 
increase in speed, as you increase the number of cores.

Yeah, one they got to multi-core, the idea of, "The language doesn't 
need to know anything about the hardware.", was lost, to some extent. 
But, then, you also get stupid things like GCC optimizing out NULL 
tests, which actually caused two Linux kernal versions to suffer a 
potential, Windows style, "root level access no matter what account you 
are on", problem. The compiler needs to be smart enough to "know" you 
are compiling for multi-cores, and warn you about such things (or avoid 
optimizing in a way that causes them). But, high level languages where 
all developed "before" this was an issue, so its not surprising its 
shown up now.

-- 
void main () {

     if version = "Vista" {
       call slow_by_half();
       call DRM_everything();
     }
     call functional_code();
   }
   else
     call crash_windows();
}

<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models, 
3D Content, and 3D Software at DAZ3D!</A>


Post a reply to this message

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