Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory vs. Performance

This has always been on my mind while programming, so I thought I'd spit it out before it actually gets to me.

What should i be more worried about? The memory the application consumes, or the performance it takes. By this I mean should I be focused upon using less memory for of the application and using more performance (eg. loading via database, and dumping it after use), or using less performance and using more memory (eg. caching)

My conditions for the application: - It's a server application, so it's not meant to be ran on desktops, etc, I have 6GB of ram, and I have a quad-core.

like image 624
TheAJ Avatar asked Dec 13 '09 23:12

TheAJ


People also ask

Does memory affect performance?

Generally, the faster the RAM, the faster the processing speed. With faster RAM, you increase the speed at which memory transfers information to other components. Meaning, your fast processor now has an equally fast way of talking to the other components, making your computer much more efficient.

Does more RAM mean better performance?

In a nutshell, installing more RAM may improve computer speed if you frequently use many programs or browsing tabs at once, or if you do memory-intensive tasks like gaming or Photoshop. Under regular use, however, a CPU upgrade will probably have a greater immediate effect on performance.

Do I need more RAM or a better processor?

A more powerful processor will help with tasks such as streaming or running multiple programs. At the same time, large amounts of RAM will help with multitasking but will primarily improve performance in complex programs and operations.

What is memory in performance?

The most important parameter characterizing the memory performance is the access time, that is, the time elapsed between a read request and the availability of the requested word. The cycle time is, instead, the minimum time between successive read requests; its inverse is the memory throughput.


2 Answers

Your question has drawn a lot of Zen Buddhism-like responses. I hope to do better.

Your memory limit is hard: If you exceed it, even if there's virtual memory, your app will crawl and you'll be the laughing stock of all.

Your CPU time is unlimited: Your app will take whatever time it needs; hopefully it will be sufficiently parallel that all 4 CPUs will be, for the most part, cooking with full steam until your app is finished.

Many Computer Science problems have a variety of solutions with various tradeoffs of memory against time. So: Be generous with memory until you use at least about half of it (if that helps; don't waste memory for the heck of it!) but stop while there's enough memory left that you don't need to worry about exceeding the limit, even in exceptional cases or accidentally.

Now that you've allocated your memory resources, you can try to tweak some more small performance gains out of your code. But don't bother overdoing it.

Done.

P.S. If it doesn't work correctly and reliably, all the preceding effort is worthless. Keep that in mind all the time!

Good luck.

like image 51
Carl Smotricz Avatar answered Jan 04 '23 02:01

Carl Smotricz


Consider the amount of data you will be dealing with and the responsiveness you require. Put some thought into the design. Build it to be maintainable, and get it working.

Then profile, and address your actual bottlenecks.

like image 41
retracile Avatar answered Jan 04 '23 02:01

retracile