Help - Search - Members - Calendar
Full Version: Swap Space And Memory Handling
Linuxhelp > Support > Technical Support

my system has 2 gb RAM and 40 gb of free hard disk spaceand red hat linux 9.0. i have a computationally intensive job to be run on the system.but, i find that although while running the code the system shows a 98.9% usage of CPU usage but only 0.8 % of swap space usage.

i felt there could be a more efficient way to use the memory available to my system.please, can anybody help me out.
polar. huh.gif
Under most circumstances, you don't want swap space to be used. When a computer uses swap, it is using hard disk space as virtural main memory ... which is hundreds of times slower than actually using memory.

Linux will only use swap memory if it is absolutely required, and it will use the absolute minimum required, by design.

If you are using lots of swap space an a regular basis, you should obtain more memory for your computer.
Linux also uses Main memory aggressively for disk caching ... it is not at all uncommon for almost all main memory to be used (98-99%) under normal circumstances. Most of the memory (as much as 75%) is cached. The system can easily drop cache and pickup main memory as required.

On a fairly loaded dual processor database server with 1 gb RAM, I have this using the top command:
Mem:  1028464k av, 1006492k used,  21972k free,      0k shrd,  104052k buff
                    335596k actv,  546740k in_d,  13868k in_c
Swap: 1052248k av,    3736k used, 1048512k free                  703268k cached

On another dual processor machine with 3 gb of RAM (my PVR with MythTV) here is my top output:
Mem:  3107852k total,  2988764k used,  119088k free,  119588k buffers
Swap:  2008116k total,        0k used,  2008116k free,  2533092k cached
thanks for ther reply,
my computer is single processor,and top command output is as follows:

CPU states: 91.8% user 8.2% system 0.0% nice 0.0% iowait 0.0% idle
Mem: 2056464k av, 824708k used, 1231756k free, 0k shrd, 32980k buff
457340k actv, 152228k in_d, 840k in_c
Swap: 2048276k av, 0k used, 2048276k free 459080k cached

on comparison to your data i found that the free memory is more in comaprison.the system is running the code at the time i took the output.

is it that i should move to multiprocessor system or is there scope for improvement. i had upgraded the RAM thinking the code would run faster but the improvement is not commendable.

please suggest something for it.thanks anyway

I will base my advice on this being a CPU intesive and not a disk intensive application ... (since there is memory present and not used as cache)

Is the process that is causing the CPU usage on 1 thread or many threads?

(look at the top several processes in top)

If it is a single thread, a multiple processor machine will not make it work faster ... but it will allow you to do other things at the same time. The only way to make a single threaded application faster is to increase the speed of the processor...

If there are more than 1 thread, each using an almost equal amount of processor time, then more processors will speed up the process.
Yes, it is a single thread program. the sysytem is IBM/pentium-4 2.0 ghz, it was inititally loaded with win-xp but i have uninstalled it. at present, when this message is written...only two processes(user process) are present
1. a.out(the code), using 93.1% of %CPU(coloumn) and 0.8% of %MEM(coloumn)
2. mozilla-bin using 0,5 % of %CPU(coloumn) and 1,7% of %MEM(coloumn).

i think therefore, the code is a CPU intensive application.
should i modify the code for multi threading( i would have to look into its possibilities) or wait for a better processor (or is there one available).

is there any problem with compatibility between pentium processor and linux?
Here is a situation where it is a single process using most of the resources (a faster processor will speed up):
10806 root      25  0 14428  12m 4396 R 33.6  0.4  0:01.01 cc1
10610 root      16  0  6348 4384 3608 S  0.7  0.1  0:01.01 python
10586 root      16  0  2012  964 1796 R  0.3  0.0  0:00.19 top

Here is a situation where there are multiple processes using the processor(s) equally (more processors can help here):
top - 06:05:05 up 5 days,  8:14,  2 users,  load average: 4.53, 3.32, 1.76
Tasks:  99 total,  5 running,  94 sleeping,  0 stopped,  0 zombie
Cpu(s): 95.0% us,  5.0% sy,  0.0% ni,  0.0% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:  3107852k total,  3101244k used,    6608k free,  128400k buffers
Swap:  2008116k total,        0k used,  2008116k free,  2307360k cached
14693 root      25  0 76964  73m 5244 R 57.8  2.4  0:05.24 cc1plus
14687 root      25  0 91692  87m 5256 R 47.8  2.9  0:07.13 cc1plus
14705 root      25  0 65408  61m 5232 R 46.5  2.0  0:03.89 cc1plus
14699 root      25  0 70056  66m 5256 R 43.8  2.2  0:04.50 cc1plus
That is a good processor ... there are some pentium processors that are faster and have hyperthreading ... but it is costly to upgrade to either a dual processor machine or to the latest processors.

There are also AMD64 bit processors and intel IA64 processors that can compute faster ... but the stable versions of linux avialable for them is costly (and currently, so are the machines). The AMD64 linux distros should be good in 6 months ... then a multiple processor AMD64 box might be the way to go for (max performance / price) if you can multi-thread the application.
thanks Hughes!

P.S. The Code by the way is a "finite element Application(engineering application)" if you know how to make multi threading for it or any suggestions please do so.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.