LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-18-2008, 08:23 AM   #1
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
What would happen if I used 100Gb of swap?


Hi,

I don't have the space to try this out at the mo, but I'm just idly wondering.. what would happen if I made a 100Gb swap partition, and opened, say, 100Gb of bitmaps or text files? Could Linux handle it? Would it run slow?
 
Old 10-18-2008, 09:20 AM   #2
mackdav
Member
 
Registered: Feb 2005
Distribution: RHEL, CentOS
Posts: 113

Rep: Reputation: 16
It would run incredibly slowly.
 
Old 10-18-2008, 09:40 AM   #3
j.todd
Member
 
Registered: Feb 2008
Location: Michigan
Distribution: Debian GNU/Linux Unstable
Posts: 144

Rep: Reputation: 16
It would be pointless. Just buy some more RAM.
 
Old 10-18-2008, 10:02 AM   #4
Mohtek
Member
 
Registered: Dec 2004
Location: Colorado
Distribution: Kubuntu/Debian/Centos
Posts: 126

Rep: Reputation: 15
If you had a 100GB swap and used 100GB of swap...

You system would still have the amount of space used by your swap-RAM to work with.

so you won't have any issues
 
Old 10-18-2008, 10:54 AM   #5
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
The amount of swap memory has nothing to do with the performance of your computer.

What does affect the speed is the speed at which you allocate memory (i.e. read data into virtual memory), and the number of cache misses per second.

When you read data in to your program (or just try to allocate space for it), and there isn't enough free space in RAM, the kernel will write a segment of RAM to swap space, to free up the RAM your process needs. While that's happening, the process requesting the RAM will pause, which may make it appear to be slow.

However, the kernel has a couple of tricks up it's sleeve. Firstly, all processes pause some of the time anyway, since each CPU switches rapidly between different processes; provided you only need a small amount of data to be loaded at a time, this pause can be done while another process is running (you need to have DMA enabled for this to work; that's why DMA seems to make such a big speed difference). Secondly, provided you have a swappiness value of greater than zero, the kernel will also spend some idle time (if it has any) copying data out to swap space before your process requests it, meaning that you are unlikely to get into the situation of having to pause the process unless you are doing nothing but reading in a large amount of data.

When you request a piece of information, you will either have a cache hit (the data is in RAM) or a cache miss (it's only in swap). The kernel will use DMA to transfer memory between cache and RAM, allowing other processes to run while the data is copying, so provided you have something like 99.95% of memory transfers result in cache hits, you should not see any slowdown at all as the CPU would be scheduling other processes to run anyway. This, of course, means that you have to read your data slowly over time, and have DMA enabled.

i.e. this type of thing should work fine: load a high resolution image, process it with some cpu-intensive operation, keeping it in memory/swap for later retrieval, and repeat a few thousand times. Whereas if you loaded all the images up-front and then processed each one back to back, it would be noticeably slower, since each one would have to be read from cache every time anyway.

But, as has been mentioned, RAM is a much more reliable way of improving your memory size without affecting program speed. (By the way, if you have a 32-bit system with less than 4Gb of RAM, there is a campile-time flag you can set in the kernel to use 32-bit addresses instead of 64-bit addresses for physical RAM; if you use this then you may see a slight speed-up. But you have to turn this off to access more than 4Gb of RAM; this is the only case where adding RAM to a Linux system will slow it down.)
 
Old 10-18-2008, 01:02 PM   #6
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Original Poster
Rep: Reputation: 39
Thanks rjlee! That's satisfied an itch. Maybe I'll try it some time, just for the hell of it. You don't think X would complain if I had, say, 10,000 windows open? Maybe I could work with small text files and get it up to 10 billion windows
 
Old 10-18-2008, 01:15 PM   #7
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Quote:
Originally Posted by openSauce View Post
You don't think X would complain if I had, say, 10,000 windows open?
Well, that's another question. It probably depends on your window manager and how many times it iterates over all open windows. Personally, I would guess that you would probably have slowdowns long before you start using swap space.

But still, feel free to experiment, and find out for certain!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mp3 player that plays Ogg >100Gb?? kingtermite Linux - Laptop and Netbook 5 05-31-2008 11:03 AM
Help..I bought a 100gb hdd and cant get it going. expat Linux - Newbie 50 10-22-2006 04:07 PM
100GB USB HD appears as 16MB sanderso Linux - Hardware 8 10-21-2006 05:55 PM
USB Maxtor 100GB freezes system newtuxuser Linux - Hardware 4 06-06-2006 08:25 AM
When does process swap happen in a system call? oldfogie Programming 3 05-03-2005 07:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration