You are not logged in.

#1 2008-02-12 19:12:37

grndrush
Member
From: Hamilton, Ontario, Canada
Registered: 2003-12-28
Posts: 136
Website

[Solved] Swap Question

I'm not really a n00bie, but no expert, either, and these are probably 'n00bie' Q's.

Hardware: Asus A8V-MX mobo, Athlon64 XP 3500+, .5GB DDR 333, 250 GB WD Cavier (IDE), homebuilt.
I realise I really need  1GB (at least) of real memory for the environment I run, but money is tight, and my mobo only has 2 DDR slots, so I'd have to buy a full 1 (or 2) GB and put my current memory in the closet.

Arch (Don't Panic) is fully current (x86_64).

I have 2 (relevant) partitions: /boot (40MB), and LVM  (16GB). both at the front of the drive.
LVM: / (3.5GB, 78% in use); /home (.75GB; 36%), and swap.

This build is about 2 months old. I boot to run level 3, and manually initiate X/KDE as needed, but I'm normally on the net; typically I'll have Thunderbird, a console session, and Firefox running most of the time. I'm bad about having a dozen (or more) Firefox tabs open (10 at the moment).

I frequent DailyKos.com. DKos runs AJAX-enhanced Scoop, which either trashes Konqueror, or Konqueror trashes it - it doesn't crash, but rendering in that environment simply does not work - open a page at that site with 200+ comments attached. If Konqueror rendered large DKos pages properly, I'd be using it.

DKos tends to have LARGE pages. I also have a large Yahoo 'home page' with 54 categories; I try not to leave Yahoo windows open, although the home page itself is almost always open. The nature of DailyKos is such that a lot of consecutive pages will be open, and left open, often for hours, constantly being updated by AJAX.

I initially allocated .5GB to swap. System ran OK, but bogged down especially bad when I opened a lot of browser tabs. In that environment (according to free, watching the 'buffers/cache used' item, and the 'swap used' item), both real memory and swap would 'typically' be roughly 50% in use,

I decided a few days ago to increase swap by 50% (to .75GB) to see the results. The system is running considerably smoother; it still gets bogged sometimes, but I realise with the hardware I'm running I can't expect miracles. Even with 3 or 4 DKos windows open, it's still quite quick.

Increasing swap had what hit me as an odd effect. Again, I have 10 windows open (no DKos ATM, but the effect is normally the same with them, also). free shows about 60% of real memory in use, but only 5MB of swap is in use. Given equivalent environments, I would have expected swap usage to go UP if there was more available. It appears that real memory has gone up, slightly (~50% to ~60%), while swap usage has gone WAY done (~50% to < 5%; < 1% this moment).

I'm an OLD ex-COBOL  roll  programmer; I've done a few moderate-size (but not commercial, production-scale) projects in VB (pre-Linux) and understand the basics of OOPS, but I'm not a C/C++ programmer at all, and reading the source isn't terribly helpful. Why did swap usage decline so drastically? I'm certainly not complaining  smile  smile  - I'm simply confused,

Does the kernel decide on a memory management scheme at boot, based on available real memory and swapspace? Why did increasing swap DECREASE swap usage, INCREASE (more subtly) real memory usage, resulting in better performance? Given the environment I'm running, is .75GB a rational/adequate swapspace size? Any suggestions on an optimal swap size? I realise I can experiment myself; I already have a bit, obviously, and and willing to do more experimenting (and will), but some direction as to what's happening behind the scenes would be helpful.

Lastly, is 'free' (properly read) the most appropriate tool for monitoring this, or should I be looking at iostat, vmstat, something in /proc?

TIA!

Keith

Last edited by grndrush (2008-02-22 19:07:38)

Offline

#2 2008-02-12 19:36:12

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: [Solved] Swap Question

I knew I saved this link for something: http://gentoo-wiki.com/FAQ_Linux_Memory_Management
HTH. smile

Offline

#3 2008-02-12 19:49:06

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: [Solved] Swap Question

I don't know the answer to all of your questions but I beleive this is how swap works, In order for the kernel to free up space on your Memory(ram), the kernel transfers data that is not currently being used to the Swap partition and when the data is needed again the kernel copies it back to your actual Memory. So Swap is only used when an application is in idle and no longer needs it's data to be directly in memory, then when that application is in use again the data is copied back to the Memory. The reason I beleive your swap usage is going down is because you're increasing the size, therefor the ratio's are not what they once were, you're still probably using the same amount of swap but since the size of the swap has been increased it doesn't seem like it. In a general rule a swap partition or swap file should be twice the size of the amount of actual memory you have, increasing your swap more than that really isn't going to make a change to how fast your system is since swap is only used when an application no longer needs it's data to be in ram because it's idle, so it's copied to swap until it's needed again. Hopefully this answers some of your questions, and for your last question I beleive it's a matter of opinion, each of those tools work equally well, I use 'top' myself.

Last edited by twiistedkaos (2008-02-12 19:49:36)

Offline

#4 2008-02-12 19:53:16

grndrush
Member
From: Hamilton, Ontario, Canada
Registered: 2003-12-28
Posts: 136
Website

Re: [Solved] Swap Question

Thanks Misfit! Reading now. I'll probably BBS.  smile

Offline

#5 2008-02-12 20:20:20

lilsirecho
Veteran
Registered: 2003-10-24
Posts: 5,000

Re: [Solved] Swap Question

One factor in swap use is ...LRU...meaning least recently used...the files you have kept open may indeed be there in swap because they aren't active,,,or some such argument...


Prediction...This year will be a very odd year!
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit!     X-ray confirms Iam spineless!

Offline

#6 2008-02-12 20:31:08

grndrush
Member
From: Hamilton, Ontario, Canada
Registered: 2003-12-28
Posts: 136
Website

Re: [Solved] Swap Question

Thanks <b>again</b> Misfit!

swappiness - exactly the kind of thing an old mainframer will enjoy playing with!

I'm not gonna mark this 'solved' until i play with it a bit, but I will do so in a couple of days or so. In the meantime, I'm still open to more input.

Thanks All.

Offline

#7 2008-02-14 03:26:53

grndrush
Member
From: Hamilton, Ontario, Canada
Registered: 2003-12-28
Posts: 136
Website

Re: [Solved] Swap Question

Misfit -

Haven't been able to *improve* things a lot with the swappiness parameter, not to the point of being noticeable, anyway. Was able to make system nearly freeze under a heavy load with it set to extreme values (10/90), but more modest settings yielded much more modest results. I did a bit of research and others haven't found it a HUGE help outside rather limited, specialized areas (I don't own a laptop, for example). IYO, is the default (60) the optimal value for a multitasking desktop with my 512MB RAM? Thanks for the article, it pointed and/or led me to google to some interesting links. But no magic bullet yet.

Or am I barking up the completely wrong tree?

Offline

#8 2008-02-14 03:35:07

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: [Solved] Swap Question

grndrush wrote:

Misfit -

Haven't been able to *improve* things a lot with the swappiness parameter, not to the point of being noticeable, anyway. Was able to make system nearly freeze under a heavy load with it set to extreme values (10/90), but more modest settings yielded much more modest results. I did a bit of research and others haven't found it a HUGE help outside rather limited, specialized areas (I don't own a laptop, for example). IYO, is the default (60) the optimal value for a multitasking desktop with my 512MB RAM? Thanks for the article, it pointed and/or led me to google to some interesting links. But no magic bullet yet.

Or am I barking up the completely wrong tree?

Isn't that the nature of all things solid-state? All or nothing? wink
I have no experience with swappiness, as my machines are nearly always gratuitously stacked with RAM, and my swap never even gets touched.
There is most likely a much smarter, and more experienced user than myself that will likely teach us both a thing or two around here.... any minute now..

Offline

#9 2008-02-14 04:43:52

grndrush
Member
From: Hamilton, Ontario, Canada
Registered: 2003-12-28
Posts: 136
Website

Re: [Solved] Swap Question

Well, I DO tend to the extreme - that'show I accumulated 3200 skydives, LOL (those are my feet in my avatar).

Having seen your various posts around here, I tend to trust your opinions a lot, but the more gray matter involved, the better.  wink  I'm likely up for a while; I'll lurk. Thanks again for your prompt and helpful suggestions.

I'm hoping it won't be that long before I can obtain RAM commensurate with my needs, The stuff IS getting rather cheap, I watch CraigsList, and Toronto is only 45 minutes away (at the right time of day); I generally watch that board more than the Hamilton one.

Thanks again.

Offline

#10 2008-02-14 13:53:07

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: [Solved] Swap Question

You're welcome, I just wish I had a better answer.
My friend down in Kentucky keeps asking me to go skydiving with him and I was really psyched to do so, despite my wife's protesting. Then I found out you have to jump strapped to another dude. lol

Offline

#11 2008-02-14 15:13:04

derekr44
Member
From: Queen Creek, AZ
Registered: 2008-02-13
Posts: 52
Website

Re: [Solved] Swap Question

I've found GSkill memory (from NewEgg) to be relatively inexpensive and very good memory for the cost, if you gather up enough cash for an upgrade.

$0.02


"Long separated by cruel fate, the star-crossed lovers raced across the grassy field toward each other like two freight trains, one having left Cleveland at 6:36 p.m. traveling at 55 mph, the other from Topeka at 4:19 p.m. at a speed of 35 mph." - Anonymous

Offline

#12 2008-02-14 15:48:55

freakcode
Member
From: São Paulo - Brazil
Registered: 2007-11-03
Posts: 410
Website

Re: [Solved] Swap Question

grndrush wrote:

Having seen your various posts around here, I tend to trust your opinions a lot, but the more gray matter involved, the better.  wink  I'm likely up for a while; I'll lurk. Thanks again for your prompt and helpful suggestions.

I guess you will find this paper interesting: Linux Performance and Tuning Guidelines from IBM

This paper covers how Linux kernel manages RAM, swap, cache, disk, and other resources, and introduces the tools and tricks used to audit and tune the system.

Have fun! wink

Last edited by freakcode (2008-02-14 15:49:29)

Offline

#13 2008-02-14 16:28:36

grndrush
Member
From: Hamilton, Ontario, Canada
Registered: 2003-12-28
Posts: 136
Website

Re: [Solved] Swap Question

Thanks Derek - it's currently available pretty cheap from individuals upgrading to DDR2 (as cheap as $20/GB), but I will check that out.

freakcode - truly appreciated. . Looking forward to the reading, Thanks.

Misfit - you have mail. wink  Blue Skies.

Offline

Board footer

Powered by FluxBB