POV-Ray : Newsgroups : povray.off-topic : As fast as C : Re: As fast as C Server Time
9 Oct 2024 20:50:28 EDT (-0400)
  Re: As fast as C  
From: Darren New
Date: 16 Dec 2008 12:47:40
Message: <4947e9bc$1@news.povray.org>
Invisible wrote:
> What this means is that any programming language that features automatic 
> memory management is instantly many hundred times slower than a language 
> using manual memory management, and there's nothing you can do about it.

Huh? Where did you come up with this factoid? GC can actually help improve 
cache hits, while manual memory management requires you to touch all kinds 
of pages at times when it might not be beneficial. For example, if you need 
to free the root of a large tree on the heap, using manual memory 
management, you now have to run through the whole tree, touching every page 
where there's a leaf, and cleaning it up. If 50 instructions later you free 
another tree, you have to do that all again, even if it's all in the same 
pages as the first tree.

Of course, the higher level the language is, the more opportunity for 
optimizations. For example, the talk on that page about what the .NET system 
does is incorrect. That's the .NET that was around when they wrote that 
sentence. You can (and always could), of course, precompile an entire 
assembly, rather than waiting for JIT - of course the data structure 
libraries don't get recompiled every time you run the program. And later 
compilers will do all kinds of cross-assembly optimizations if you want, in 
a way that would be very difficult for a C compiler to manage (like taking 
unused slots out of a struct to save memory).

> But still, there's nothing that anybody can ever do about it, so I guess there's no
point worrying about it...

Sure there is. Slow your CPU down a whole bunch. Happy now?

-- 
   Darren New, San Diego CA, USA (PST)
   The NFL should go international. I'd pay to
   see the Detroit Lions vs the Roman Catholics.


Post a reply to this message

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