Archived

This topic is now archived and is closed to further replies.

-XGathor-

What's wrong with a large code?

Recommended Posts

-XGathor-    122
Can someone tell me what there is wrong with a large code? Lets say i had a final executeable at a size of 5 mb cuz i used lots of macros and inlined functions to make my code faster? The problem cant be hard disk space. Is it something about that all the code has to be in memory during executing???. -René

Share this post


Link to post
Share on other sites
nails    122
Careful with large code -- you might be surprised to see that as your code is running along inside a memory page, you''re about to execute an instruction that resides on a different memory page. That page then needs to be read off of disk, brought into physical memory, and then executed. Then you have a chance of losing the originating page if you''re under especially heavy memory pressure.

But cache misses are the biggest problem here, because they''re much more likely to happen. Small code is important, but good algorithms are the most important.

You might find that repeating a lot of code with macros and so forth yields expressions where you are throwing away the results of calculations you already made...

Share this post


Link to post
Share on other sites
JonStelly    127
Well, Windows loads executables as memory mapped files so the entire executable isn''t loaded directly into memory when you double click. Instead, it is paged into memory from disk when execution enters a section of the executable that hasn''t been loaded yet.

The biggest problem, as people have pointed out is one of locality and cache misses. Inline functions can easily result in a performance loss if you overuse them. The rule I use is to only inline functions that I would have written as Macros. Simple functions only containing a few lines (<15).

Share this post


Link to post
Share on other sites