What's wrong with a large code?

Started by
3 comments, last by -XGathor- 23 years, 7 months ago
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é
Advertisement
The problem is one of locality and cache misses...
That''s why you wan''t to keep your code lean and mean.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
I believe they have a word for that kind of stuff: "Bloatware."

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
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...
jrt
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).

This topic is closed to new replies.

Advertisement