Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
05-16-2006, 04:00 AM
|
#1
|
Senior Member
Registered: Mar 2006
Distribution: SLACKWARE 4TW! =D
Posts: 1,519
Rep:
|
Swap file tweaking? Do they work?
Hi all,
Just wondering if you guys have had any success with tweaking swap files.
I've been perusing the net and see people make claims you can have two swap file s on one hard drive, then another was to using flash memory as swap and act as raid swap.
Do any of those tweaks really work?
Does anyone know of a good swap file tweak?
Do they even exist for a one hard drive type of installation?
Thanks.
|
|
|
05-16-2006, 04:34 AM
|
#2
|
Slackware Contributor
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559
|
I think, on a one-disk computer there is little or no room for tweaking the swap. What I would never do is put swap on a flash disk. These media can be written to reliably only a specified maximum number of times (per sorage cell), and a swap file will be internsively used.
It becomes more interesting when you have more than one hard disk, and are able to create multiple swap partitions on multiple drives. The swapped-out pages can be written to and read from more than one drive which should speed things up a little. Or even, in a two-disk system, have the swap on one disk and the partition(s) containing log/var directories on the other. The log- and var are quite actively written to at all times and you would want to avoid to have the swap partition on the same drive.
I never felt inclined to use raid-ed swap. To me it would make more sense to use all those partitions as separate swap partitions. You are allowed to have more than one partition for swap; this is taken from my own server at home -
Code:
# cat /etc/fstab |grep swap
/dev/hdc1 swap swap defaults 0 0
/dev/hda1 swap swap defaults 0 0
/dev/hdb1 swap swap defaults 0 0
|
|
|
05-16-2006, 05:25 AM
|
#3
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,286
|
Seems a very sensible post.
The best I/O is no I/O - get some more memory if you want to really improve swap performance on a single-disk system.
IMHO, raid-ing swap is likely to be counter-productive.
|
|
|
05-16-2006, 02:42 PM
|
#4
|
Member
Registered: Mar 2005
Location: Right behind you.
Distribution: NBG, then randomed.
Posts: 480
Rep:
|
Yep. If you're using swap to any significant degree it's a sign that you need to just buy some more RAM.
Minor uses of swap are quite normal. The kernel, left to it's own, can and will push some things that aren't being used and haven't been for awhile out to swap to free up more space for filesystem caching.
Swap on flash disk is just silly. Not only will this rapidly demolish flash disks as was posted previously, it's typically slower than just using a decent IDE disk. Attempting RAID is just as silly, since if you have two disks you might as well just put the swap partition on the disk that's less used. Two swap partitions on the same disk (unless you really need gigantimungous amounts of swap space, which means you're probably using 8Gb of RAM already) is just stupid. Two partitions on the same disk won't write any faster than one partition will and the bottleneck is the disk itself, not the IDE bus.
About the only thing you can do to speed up swap is make sure it's on the "end" of the disk that's faster. (Yes, different parts of the disk actually access more quickly.) Unlike older drives that would have a lot of platters wedged in there, the newest drives tend to only have between one and three really high density platters in them. The majority case of these make the beginning of the disk slightly faster, and with others it's the end of the disk. You can use bonnie++ or some um... "interesting" invocations of dd & time to find out which "end" of your disk is faster, but it's probably easier to just make a small partition at the start and end of your disk and test with dd from the bootable CD.
If you can't tell the difference, or if it's so small you can't be sure there is a difference, work from the "use" case and stick it in between say, your /usr and /var partitions on the disk in hopes that the heads don't have to chase all over as much. It's much less of an issue if your drive actually has a larger cache built into it, since it'll be able to optimize it's own use of reads and writes better. Under heavy loads I can actually measure a difference in access times between my 2mb cache and my 8Mb cache, provided I'm not pounding the holy wonderstuff out of the disk.
Last edited by evilDagmar; 05-16-2006 at 02:44 PM.
|
|
|
05-16-2006, 02:46 PM
|
#5
|
Member
Registered: Mar 2005
Location: Right behind you.
Distribution: NBG, then randomed.
Posts: 480
Rep:
|
Quote:
Originally Posted by Alien Bob
I never felt inclined to use raid-ed swap. To me it would make more sense to use all those partitions as separate swap partitions. You are allowed to have more than one partition for swap; this is taken from my own server at home -
Code:
# cat /etc/fstab |grep swap
/dev/hdc1 swap swap defaults 0 0
/dev/hda1 swap swap defaults 0 0
/dev/hdb1 swap swap defaults 0 0
|
I thought it usually filled up the first one available and then went onto the others. Still, it can't hurt to have more of it around. Do you have any way to investigate this more closely? It would be good info to have, for certain.
(Final note unrelated to this use. Swap on LVM is also a little silly. The less computational overhead involved when accessing swap, the better.)
Last edited by evilDagmar; 05-16-2006 at 02:47 PM.
|
|
|
05-16-2006, 02:51 PM
|
#6
|
Slackware Contributor
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559
|
Quote:
Originally Posted by evilDagmar
I thought it usually filled up the first one available and then went onto the others. Still, it can't hurt to have more of it around. Do you have any way to investigate this more closely? It would be good info to have, for certain.
|
I created my own swap partitions and added them to /etc/fstab manually.
Edit: I guess I didn't understand your question at first, but Chinaman fixed that... to see how the sswap files are used, look in /proc :
Code:
# cat /proc/swaps
Filename Type Size Used Priority
/dev/hdc1 partition 136512 136504 -1
/dev/hda1 partition 257000 124308 -2
/dev/hdb1 partition 136512 0 -3
The swap files have a proirity attached (displayed when the swap is activated) which seems to determine the order in which they are used.
Eric
Last edited by Alien Bob; 05-16-2006 at 05:07 PM.
|
|
|
05-16-2006, 05:08 PM
|
#7
|
Slackware Contributor
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559
|
I added some more info to the previous post
Eric
Last edited by Alien Bob; 05-16-2006 at 05:09 PM.
|
|
|
05-17-2006, 08:10 AM
|
#8
|
Moderator
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,961
|
Quote:
Originally Posted by Old_Fogie
Hi all,
Just wondering if you guys have had any success with tweaking swap files.
I've been perusing the net and see people make claims you can have two swap file s on one hard drive, then another was to using flash memory as swap and act as raid swap.
Do any of those tweaks really work?
Does anyone know of a good swap file tweak?
Do they even exist for a one hard drive type of installation?
Thanks.
|
Hi,
First are you speaking about temporary or permanent swap files or swap space? There is a big difference here. A temporary swap file can be a file within the filesystem tree. A permanent swap or swap space is a partition allocation on the hard disk or storage media.
With the availability of new storage media the use of temporary swapfiles are now a new and faster means of using this technique. In the past the use of swapfiles was prohibitive due to the time vs space issue. We were limited by the amount of ram that could be allocated for ram disk storage to allow the fast exchange of data via I/O.
The use of the permanent swap space on a hard disk provided the means to have a larger allocation of space but with the sacrifice of time since a mechanical device was being used for the I/O.
Yes, today everyone seems to use the term swapfile to imply the use of a hard disk partition space as the means of virtual memory storage area. But as stated above the swapfile indeed started with the use of a physical memory space for the virtual memory. That physical space could be within the filesystem or a generated space within a memory (ram) area.
With the new flash memory and other memory based devices getting into the gig range at a small cost. The use of a permanent swapfile will be a lot faster at affordable cost per byte of desired storage. Therefore the virtual memory indeed will be faster and used over multiple devices without sacrifice of I/O data exchange.
|
|
|
05-17-2006, 08:35 AM
|
#9
|
Member
Registered: Mar 2005
Location: Right behind you.
Distribution: NBG, then randomed.
Posts: 480
Rep:
|
Yeah, uhuh. Benchmark your throughput on a USB thumb drive and compare that to that of a decent 7200RPM ATA disk. Note that one of these is a lot slower than the other, as well as one of them is cooked and dead within six months. It sounds like someone's been pounding the theoretical into you and utterly ignoring the practical, and you're the only person here who was confused about what the OP meant by 'swap'.
|
|
|
05-17-2006, 09:33 AM
|
#10
|
Moderator
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,961
|
Quote:
Originally Posted by evilDagmar
Yeah, uhuh. Benchmark your throughput on a USB thumb drive and compare that to that of a decent 7200RPM ATA disk. Note that one of these is a lot slower than the other, as well as one of them is cooked and dead within six months. It sounds like someone's been pounding the theoretical into you and utterly ignoring the practical, and you're the only person here who was confused about what the OP meant by 'swap'.
|
Hi,
I'm not confused about the issue. Just expanding on the thought.
There are other memory storage techniques that can be used!
You do show some intelligence about the use but did not expand on the issue. As for the use of thumb drives and the reliability of said device. That will depend on the quality of device chosen.
We have had ramdisk cards for a long time and these were used for just this discussed technique. With the cost of memory going down and the density going up then the ramdisk card will be used even more.
Memory storage cards or ramdisks with backup means are available to use for this very issue. You do not have to use the removable devices. The OP stated the use of the removable devices for this use. If I were to setup a system with this criteria then a memory card in the 20-30 GB would be selected. Yes the cost would be high but with the data exchange I/O time being low compared to your benchmark of a 'decent 7200RPM ATA disk' would be worth it. Most high end servers implement this technique. Computation analysis servers use this technique because of the load overhead.
Theoretical has a lot to do with this and your presentation to defend your position by putting an opinion down because of your view being put to test is not warranted. As I pointed out a lot of people use the term swapfile synonymously to mean the exchange within the hard disk partition.
When the term swapfile or temporary swapfile is indeed used then the data is exchanged between a storage media that is not permanent. The term permanent swapfile is in the use of a media that can retain the data over a long term such as hard disk or nonvolatile memory.
Yes, I come from academia where the theoretical along with practical are used all the time. You must understand how to use each to support said environments.
If I have offended you about the expansion of the thought then it seems you don't understand the whole issue.
|
|
|
05-17-2006, 10:54 AM
|
#11
|
Moderator
Registered: Aug 2002
Posts: 26,352
|
Thumb drives, ramdisk and PCMCIA cards use different technology. Thumb drives use flash memory which does have a limited number of write/erase cycles. Typically a single flash memory cell has 100,000 write/erase cycles but due to smart logic the entire device is supposed to have a lifespan of 1,000,000+ write/erase cycles. RAMdisk cards typically use battery backed DIMMs and are not limited by write/erase cycles. PCMCIA memory cards come in both flash and SRAM model. SRAM is battery back which also does not have a limited write/erase cycle.
|
|
|
05-18-2006, 08:26 AM
|
#12
|
Moderator
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,961
|
Quote:
Originally Posted by michaelk
Thumb drives, ramdisk and PCMCIA cards use different technology. Thumb drives use flash memory which does have a limited number of write/erase cycles. Typically a single flash memory cell has 100,000 write/erase cycles but due to smart logic the entire device is supposed to have a lifespan of 1,000,000+ write/erase cycles. RAMdisk cards typically use battery backed DIMMs and are not limited by write/erase cycles. PCMCIA memory cards come in both flash and SRAM model. SRAM is battery back which also does not have a limited write/erase cycle.
|
Hi,
Agree with the technology terms of the type of devices. I was expanding on the use of the ramdisk/memory card as a storage media. The memory card in use in most high end applications are pci or pci-x based.
If you need large memory maps the use of pcmcia based units limit this option.
|
|
|
05-18-2006, 09:59 AM
|
#13
|
Member
Registered: Aug 2004
Location: Aguascalientes, AGS. Mexico.
Distribution: Slackware 13.0 kernel 2.6.29.6
Posts: 816
Rep:
|
Quote:
Originally Posted by Alien Bob
The swap files have a proirity attached (displayed when the swap is activated) which seems to determine the order in which they are used.
|
That's correct, though I have this doubt:
I'm understood that if you set them swap partitions the same priority (with pri=N in the fstab), they work like RAID 0 among the different hard drives, does anyone know if that is right?
I have them that way on 2 hard drives (one S-ATA, one P-ATA) though the damn machine seems to never use the swap (has 2 gigs of RAM )
|
|
|
05-18-2006, 05:57 PM
|
#14
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,286
|
Quote:
Originally Posted by gwsandvik
The memory card in use in most high end applications are pci or pci-x based.
|
Given the fact that the PCI bus is so slow, and (apparently) your active working set is large, is 64-bit kernel with *large* RAM not a better option ???.
Keeping more of the working set in storage,and kswapd out of the picture at all might be the aim.
As alway, there will be "depends" - depends on the application, depends on the money, ...
|
|
|
05-18-2006, 06:04 PM
|
#15
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,286
|
Quote:
Originally Posted by raska
I'm understood that if you set them swap partitions the same priority (with pri=N in the fstab), they work like RAID 0 among the different hard drives, does anyone know if that is right?
|
I was also of this mind. Maybe just wishful thinking on our part. A quick (and I mean quick) look at the code implies differently. Seems one swap extent will always be traversed first looking for appropriate free (cluster or other) swap slots, before the next extent is checked.
Something else to test sometime ...
Edit: Finally got round to some (simple) testing.
My code reading was remiss - multiple swap extents (at the same priority level) will be used concurrently.
Sorry if I misled anyone.
Last edited by syg00; 07-13-2006 at 10:55 PM.
|
|
|
All times are GMT -5. The time now is 02:48 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|