Swap space questions

Booting, installing, newbie
Message
Author
User avatar
gary
Posts: 89
Joined: Fri 21 Dec 2007, 18:14
Location: Cartersville, GA

Swap space questions

#1 Post by gary »

In Htop I see my swap space, but no activity in spite of how many apps I try to run concurrently, so I have some general questions about swap...

1) Does more swap space improve (or degrade???) performance?
2) Is it enough to simply create a swap partition (formatted ext2 swap) in Gparted, or does linux have to be configed to use it?
3) What tool or util allows me to see swap activity to make sure it is being utilized?
4) Is swap used all the time or only when the system and apps exceed the physical RAM available?

Athlon 1800+
512meg RAM
1Gig swap partition
Lupu 5.2 full install
[b]Hasten Slowly![/b]

User avatar
Béèm
Posts: 11763
Joined: Wed 22 Nov 2006, 00:47
Location: Brussels IBM Thinkpad R40, 256MB, 20GB, WiFi ipw2100. Frugal Lin'N'Win

#2 Post by Béèm »

1) a swap of 512MB will be enough. Don't know if your 1GB swap will have an incidence on performance. I don't think so.
2) Yo can use a swap file or a swap partition. If you go for a partition gparted will make it. Then there is no talk about ext2. At boot puppy will detect it.
3) type free in a terminal.
4) swap is only used when needed
Time savers:
Find packages in a snap and install using Puppy Package Manager (Menu).
[url=http://puppylinux.org/wikka/HomePage]Consult Wikka[/url]
Use peppyy's [url=http://wellminded.com/puppy/pupsearch.html]puppysearch[/url]

User avatar
duke93535
Posts: 194
Joined: Thu 05 May 2005, 16:45
Location: California , High Desert

#3 Post by duke93535 »

Gary:

I just have a swap partition for general principles, I have 4 gb of memory and never see the swap used, not even compiling an app. It is only used when you run out of normal memory. Gparted will show you if it is seen and ready to be used. It will have a lock icon on the swap partition when you open Gparted.

Even with 512 mb I don’t think you will use it often. In your case I wouldn’t go any larger than what you have for swap partition, since it seem that you are not using it anyway most of the time. You might cut the swap size, if you need the space, to say 512 mb. Hardinfo will show you the usage under the memory tab and clicking cached swap, if you have any.

duke

stu90

#4 Post by stu90 »

I have 1gb of swap and 875mb of Ram - i can't recall ever seeing swap being used.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#5 Post by Flash »

For years I've been running Puppy from a multisession DVD (which loads Puppy entirely into RAM) in a computer without a hard disk drive. No hdd means no swap memory. My present computer has 4 GB of RAM, but my previous computer had "only" 256 MB of RAM at first, later increased to 512 MB. The only time I ran out of memory was when I attempted to install OpenOffice in the computer with 256 MB of RAM.

My conclusion is, if you have more than 256 MB of RAM, swap memory will probably never be used at all.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#6 Post by disciple »

If you have the disk space available I think Ram+Swap=1G is a good idea.

I can't see how more swap could degrade performance, although I've seen people with very low ram claim that it does.
2) Is it enough to simply create a swap partition (formatted ext2 swap) in Gparted, or does linux have to be configed to use it?
A swap partition is normally used automatically (a swap file is not though). But I thought it was called "linux swap" rather than "ext2 swap" ;)
4) Is swap used all the time or only when the system and apps exceed the physical RAM available?
It is used when the linux decides it is needed. I understand Linux has very good memory management so you needn't worry about it :)
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

Bruce B

#7 Post by Bruce B »

gary wrote:In Htop I see my swap space, but no activity in spite of how
many apps I try to run concurrently, so I have some general questions
about swap...

1) Does more swap space improve (or degrade???) performance?
I calculate over a period of time what is my worst case scenario, then
make the space somewhat larger than that.

If that's how I do it, it must be that I think having an excess of swap is of
no value.

I can't image how it would be advantageous to have more swap than you
will ever use, can you?
2) Is it enough to simply create a swap partition (formatted ext2 swap) in
Gparted, or does linux have to be configed to use it?
ext2 is a Linux file system

I don't think swap is file system in the ordinary sense. I think it is better
thought of as allocated space.

I use swap files. Nearly all Linux distros wouldn't know about my swap
files, so I have to instruct the OS to use them.

When using a swap partition most Linux distros will find it and activate it.
3) What tool or util allows me to see swap activity to make sure it is
being utilized?
free is a common CLI tool which will show you
4) Is swap used all the time or only when the system and apps exceed
the physical RAM available?
Swap is a storage place. Linux decides under what circumstances it wants
to use it.

If you run apps in excess of the RAM, it is pretty certain Linux will want
to use some swap space.

It will use swap space under other circumstances, as it sees fit, but that
is more rare.

sfeeley
Posts: 812
Joined: Sun 14 Feb 2010, 16:34

#8 Post by sfeeley »

interesting--my swap partition seems to be used a bit more than some people would indicate. Even when the Ram is not fully used. <<see attached image>>
that's with firefox + 4 tabs (but the tabs only have puppy forum pages, so nothing intensive)


I think I recall somebody saying that if your swap is too big it slows down the computer. I think the explanation was that Puppy gets too "eager" to use it instead of Ram

On a different old computer with low ram, firefox would crash on me anytime I had anything with flash or memory intensive until I put in a swap.
Attachments
ram_swap_pic.jpg
(64.08 KiB) Downloaded 671 times

Bruce B

#9 Post by Bruce B »

sfeeley,

Here is the current state of RAM and swap

Code: Select all

             total       used       free     shared    buffers     cached
Mem:        510192     494708      15484          0     120208     224744
-/+ buffers/cache:     149756     360436
Swap:       524280      23492     500788
Displayed in Megabytes

Code: Select all

             total       used       free     shared    buffers     cached
Mem:           498        488         10          0        114        220
-/+ buffers/cache:        152        345
Swap:          511         22        489
I have 10MB free RAM, but actually much more is free because 334MB is
in buffers and cache. Some of this buffers/cache Linux would likely
release if I started new processes.

I can determine how much Linux will give up. I'll do this later in the post.

The Mem: line is real time usage.

The Swap: line needs more interpretation. The swap file has 22MB worth
of pages. Linux moved from RAM to swap earlier. It is not using it
now. As the computer operator I can say the chances are the data won't
be used.

Linux on the other hand doesn't know what I'll do next. There is no
reason to empty the pages, so it just lets it sit there in the event I
repeat something in such a way Linux wants some of the data it
previously paged.

Back to RAM. I was watching movies earlier and doing other memory
intensive things.

Linux doesn't know what I'll do later, but on the theory that we tend to
repeat what we did earlier, Linux 'uses' RAM it doesn't need, because if
it does need the data again, it will already be there, thus improving
performance.

In the next display I can show how much Linux will give up from RAM.

Code: Select all

             total       used       free     shared    buffers     cached
Mem:           498        205        292          0          0         59
-/+ buffers/cache:        146        352
Swap:          511         22        489
After flushing the RAM, Linux let go of 282MB data.

Linux might hold on the the paged data for the duration of this session.
It's not hurting anything, even though I know the data won't be used
again, Linux doesn't know. Because it doesn't hurt, then leave it.

I'd like to add that if I had no swap device, I feel confident Linux would
have managed just fine. My practice is to always have a swap device
activated. This way if Linux wants to page some data, it can.

Bruce

~

User avatar
gary
Posts: 89
Joined: Fri 21 Dec 2007, 18:14
Location: Cartersville, GA

#10 Post by gary »

Thanks for the all opinions and explanations. Memory has become cheap since early years and I'm not sure if the same MMU methods are employed anymore. My first system was a DEC VAX-11/780. I remember it only having 8meg of physical memory, but perhaps 100meg of virtual memory. Back then, it would have been inconceivable to have the amount of physical memory that we take for granted today; i.e., expensive physical memory was used sparingly and always 100% utilized. I always understood that the entire task list for all simultaneous users was overlaid on the virtual memory (swap), and the physical memory "slid around" on the virtual memory map depending on what the CPU(s) needed access to at any given moment. So the virtual memory contained the larger multi-user multi-task map (I think the VAX supported 64 users). I only mention this because if the same methods are still employed then it seems the swap space would still contain the overall task map even tho the physical memory may be able to hold the entire active task list at any given time. With the huge physical memory today, it almost seems the roles of physical and virtual have reversed; i.e., the physical memory typically holds everything, but when it can't, only then does it write stuff out to virtual.

In any case, I was initially concerned because I didn't know if there was anything more required to use swap other than declaring it as linux swap in Gparted? It sounds like that question has been answered. Thanks.
[b]Hasten Slowly![/b]

User avatar
gary
Posts: 89
Joined: Fri 21 Dec 2007, 18:14
Location: Cartersville, GA

#11 Post by gary »

1) Does more swap space improve (or degrade???) performance?
I calculate over a period of time what is my worst case scenario, then
make the space somewhat larger than that.

If that's how I do it, it must be that I think having an excess of swap is of
no value.

I can't image how it would be advantageous to have more swap than you
will ever use, can you?
Is more swap advantageous? Well maybe... I would like to have more money, but not more money than I would ever use! So the question becomes: when does more become too much? (don't answer - it's a rhetorical question).

Does too much swap cause degraded performance? Another analogy... you can't remember all your satellite channels, so you have a quick reference card. But what if, instead, the sat company gave you a 50 page manual of channel info? I'm not technically privy to how the MMU accesses the swap memory, so it's difficult to determine if more takes longer?

Many of these questions could be answered empirically. In fact, I'm tempted right now to replace my 512meg of RAM with 64meg just to see what would happen? I just thought I'd get some other's opinions and tap their knowledge on the swap subject.
[b]Hasten Slowly![/b]

User avatar
rjbrewer
Posts: 4405
Joined: Tue 22 Jan 2008, 21:41
Location: merriam, kansas

#12 Post by rjbrewer »

If one is using an os that has hibernation and wants to use it; a
swap space slighty larger than installed ram is necessary.

Inspiron 700m, Pent.M 1.6Ghz, 1Gb ram.
Msi Wind U100, N270 1.6>2.0Ghz, 1.5Gb ram.
Eeepc 8g 701, 900Mhz, 1Gb ram.
Full installs

User avatar
gary
Posts: 89
Joined: Fri 21 Dec 2007, 18:14
Location: Cartersville, GA

#13 Post by gary »

OK, I did it. I couldn't find a 64meg DDR (did they ever even make them that small in DDR?), but I did find a 128meg stick and tried that. I had to load up quite a few apps on both desktops, but finally the system began using the swap space, and of course, things began slowing way down after that. Free was showing about 35meg of swap utilized after loading the browser, write, calc, edit, and paint, in both desktops. Also HTop was showing slight swap space utilization (one bar) in the graph. Keep in mind this is a full 520 install, but I'm surprised that even with only 128meg, it seems the system would run fine for most everyday use.
[b]Hasten Slowly![/b]

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

Re: Swap space questions

#14 Post by RetroTechGuy »

gary wrote:In Htop I see my swap space, but no activity in spite of how many apps I try to run concurrently, so I have some general questions about swap...

1) Does more swap space improve (or degrade???) performance?
2) Is it enough to simply create a swap partition (formatted ext2 swap) in Gparted, or does linux have to be configed to use it?
3) What tool or util allows me to see swap activity to make sure it is being utilized?
4) Is swap used all the time or only when the system and apps exceed the physical RAM available?

Athlon 1800+
512meg RAM
1Gig swap partition
Lupu 5.2 full install
I'd say that looks fine. I've got a 1.6GHz P4, 768MB RAM, 1.2GB swap. I'm running Lupu 520 as a frugal install (along with WinXP).

In the old days (when memory was expensive, and small) it was generally recommended that you use a swap twice the size of your RAM (many systems only had 32MB, perhaps 64MB).

Nowadays, RAM is so cheap and generally so large, that you don't as easily crash into memory barriers...

On the flip side, as the swap gets very, very large, your computer must keep track of that space, so an exceptionally large swap could slow down your machine...

It almost seems that a Puppy system runs better if it has a swap partition, even if it doesn't use it. Seems strange, but without a swap, I suspect that the OS spends more time making sure it doesn't run out of memory (works harder to free unallocated, but "consumed" memory). I don't know the inner details of the kernel, but that's what it empirically appears to me...
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#15 Post by jpeps »

If you want to increase/decrease swap usage, edit /proc/sys/vm/swappiness. It's generally set at 60. Setting lower decreases usage.

User avatar
gary
Posts: 89
Joined: Fri 21 Dec 2007, 18:14
Location: Cartersville, GA

#16 Post by gary »

Ahhh, now that's an interesting tidbit! I have assumed the full lotus position and am eagerly awaiting full swappiness.

Thanks jpeps
[b]Hasten Slowly![/b]

Dewbie

#17 Post by Dewbie »


disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#18 Post by disciple »

Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.
I don't get it. Why can't the application tell Linux to throw all those pages away?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
gary
Posts: 89
Joined: Fri 21 Dec 2007, 18:14
Location: Cartersville, GA

#19 Post by gary »

What if you relaunch the same app tho? Many of the pages might still be valid and thus not need to be reloaded again. It's probably a similar methodology to flushing cache; i.e., why make the effort until you need to? Reclaiming memory resources can be handled as new data comes in, and doesn't take anymore time. Until then, it doesn't hurt to leave the data intact.

For instance, I have noticed that when running large progs, if I exit, then relaunch the same prog, it doesn't take nearly as long the second time around providing I haven't executed too many other tasks in between.

BTW disciple, Just noticed your sig... I remember in olden days when the computer salesmen would say "it's just like a Mac". LOL
[b]Hasten Slowly![/b]

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#20 Post by disciple »

Sorry, I meant "why can't the app tell linux that those pages aren't needed, so it can throw them away if it needs to?"
Maybe I misunderstood and it does do this, but I don't think so.
For instance, I have noticed that when running large progs, if I exit, then relaunch the same prog, it doesn't take nearly as long the second time around providing I haven't executed too many other tasks in between.
Yes, but if you don't close the program and you execute a lot of other tasks, does a second instance of the program start up slowly? I don't think so.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

Post Reply