Whats the least bad , memory or CPU overhead?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
Peterbjornx
Member
Member
Posts: 116
Joined: Thu May 06, 2010 4:34 am
Libera.chat IRC: peterbjornx
Location: Leiden, The Netherlands
Contact:

Whats the least bad , memory or CPU overhead?

Post by Peterbjornx »

I am writing some utility routines at this moment and i was wondering, should i add a cache for results or should i just have it fetch the result every time?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Whats the least bad , memory or CPU overhead?

Post by Solar »

...then think about if it's worth the bother to optimize the code, then optimize it, then measure the performance again (because you might have made it worse, or introduced less-maintainable code for a neglectible performance gain).

Hence the mantra of optimization: measure, optimize, measure.
Every good solution is obvious once you've found it.
OSwhatever
Member
Member
Posts: 598
Joined: Mon Jul 05, 2010 4:15 pm

Re: Whats the least bad , memory or CPU overhead?

Post by OSwhatever »

An interesting question is how do you profile your code in your OS?

There are a lot of good tools for code performance profiling that will not work on a OS for scratch.
madeofstaples
Member
Member
Posts: 204
Joined: Thu Apr 12, 2007 8:15 am
Location: Michigan

Re: Whats the least bad , memory or CPU overhead?

Post by madeofstaples »

It depends, of course, on the realistic constraints of the particular project.

In theory, of course, space is more powerful than time.
Some people are offended by the verifiable truth; such people tend to remain blissfully unencumbered by fact.
If you are one of these people, my posts may cause considerable discomfort. Read at your own risk.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Whats the least bad , memory or CPU overhead?

Post by gravaera »

Your project's hardware target has a lot of impact on which you trade off usually also. You can generally decide which path to take when you have to choose based on your own goals. "Must fit in 1.44MB" will obviously make you want to optimize more aggressively for space than for speed.

--All the best,
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: Whats the least bad , memory or CPU overhead?

Post by salil_bhagurkar »

I use -finstrument-functions, and then output the function address and processor timestamp on each function entry and exit, on the serial port, which Qemu outputs to a file :mrgreen:
Then I externally parse this file to match each address with the linker map and print out a table for each function and its average time spent, and number of entries into it.

This gives me a fair idea of performance problems.
Post Reply