You are not logged in.

#1 2012-06-04 20:10:46

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

Swap on uncompressed ramdisk - useless?

Since I'm no longer using a swap partition...

I used to figure that mounting a ramdisk as swap was worse than useless. However, now that I know a bit more about paging, I'm wondering if having a dedicated ramdisk to act as a page cache would actually be helpful. Is the Linux kernel smart enough not to need this, or would it help make more efficient use of RAM?

Offline

#2 2012-06-04 20:12:40

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,417
Website

Re: Swap on uncompressed ramdisk - useless?

How much RAM do you have?  My machine has 8 G and I have *never* used a swap partition.  Swap is an antiquated thing on modern hardware.

Last edited by graysky (2012-06-05 01:40:00)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2012-06-04 22:55:34

WorMzy
Forum Moderator
From: England
Registered: 2010-06-16
Posts: 5,019

Re: Swap on uncompressed ramdisk - useless?

I don't see any point in dumping currently unneeded information loaded into RAM onto another part of the RAM so that other information can be loaded into RAM. That whole process seems redundant to me.

If you frequently find that you're filling up your RAM, and don't want to create a disk based swap file/partition, I suggest that you switch to lighter applications, and/or install more RAM in your PC.


Sakura:-
Mobo: ASUS P8Z77-V PRO // Processor: Intel Core i7-3770K 3.4GHz // GFX: nVidia GeForce GTX 970 Ti // RAM: 32GB (4x 8GB) Corsair DDR3 (@ 2133MHz) // Storage: 1x 3TB Seagate SATAII 5x 1TB Samsung SATAII, 2x 120GB Corsair SSD

Offline

#4 2012-06-05 20:31:42

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 947

Re: Swap on uncompressed ramdisk - useless?

graysky wrote:

How much RAM do you have?  My machine has 8 G and I have *never* used a swap partition.  Swap is an antiquated thing on modern hardware.

Only on a desktop. In a large cluster environment with lots of users, 64G is nothing and swap fills pretty quickly.


Arch Linux is more than just GNU/Linux -- it's an adventure

Offline

#5 2012-06-06 03:26:04

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 12,396

Re: Swap on uncompressed ramdisk - useless?

I dunno,  I almost never use it ... but it is there to allow a graceful degradation instead of a sudden disaster.

Never mind-- I missed the RAM disk part.

Last edited by ewaller (2012-06-06 03:26:49)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Like you, I have no idea what you are doing, but I am pretty sure it is wrong...Jasonwryan
----
How to Ask Questions the Smart Way

Offline

#6 2012-06-08 12:08:41

PReP
Member
From: Sweden/Sala
Registered: 2010-06-13
Posts: 347
Website

Re: Swap on uncompressed ramdisk - useless?

I haven't used swap in quite a while either,
neither when i had 2GB of ram, nor now that i have plenty more.

The only thing that has ever "happened" in my usercase is Java->Minecraft getting smootly killed sometime when it leaked and ate RAM like a glutton.

This atleast makes me feel nice about linux managing and saving ones arse efficently smile


#1 Main: Intel Core i5 2500k (Sandy) @ 3.9 Ghz, 8 GB DDR2-XMP RAM @ 1600 Mhz, Geforce GTX 570 (Gainward Phantom) - Arch Linux 64-Bit
#2 Server: Intel C2D E8400 @ 3.6 Ghz, 3 GB DDR2-RAM @ 802mhz, XFX GF GTX260 XT -ArchLinux 64-bit.

<- Server Homepage: http://prep.mine.nu ->

Offline

#7 2012-06-17 09:42:22

Spacenick
Member
From: Germany
Registered: 2010-04-02
Posts: 168

Re: Swap on uncompressed ramdisk - useless?

I've got 16 gig of RAM and have stopped using swap as well.
The problem with swap on desktops with a lot or RAM is that it only really gets used when some process goes crazy because, databases and the like never try to use more RAM then they can so they don't run into swap either even though they can often potentially use as much RAM as you can throw at them.
This leads to the problem that when swap is used things crawl to a halt until the swap is full and the OOM killer shoots down a process (in newer kernels it really often finds that broken process and kills that first).
So you're just sitting there unable to do anything usefull until the culprit is killed.
Without swap on the other hand the OOM killer is started right away, kills the process gone crazy and you can work on. I find this extremely helpful especially when developing software that under normal circumstances takes roughly 8 gig ram where a small bug can easly make it grow indefinitely.. for example when fooling around with template meta programming you can easily make gcc take huge amounts of RAM (I've seen a program that computed primes with templates that could be compiled with less than 16 gig of RAM)
And Linux is really intelligent about using ram, it will have thrown away any filesystem caches long before the OOM killer gets started.
The only real problem is that swap is used for hibernate, I guess one could tune the swappiness of the system so it doesn't use it for anything else but I haven't bothered because I just don't use hibernate.
On servers things seem to be different even though I'm not sure I'd really use swap on a server that nobody but me has to trust..It's not like a server that's waiting on swap is any use..
However in theory it makes things more stable. Still I've never seen any of the servers I admin do anything usefull with swap, even though I've seen development servers that were really hard to get under control because they were swapping and so even ssh crawled to a halt (and the slowness of swap becomes even worse when you got > 24 GB of RAM and just as much swap)

Offline

#8 2012-06-19 07:48:40

blackout23
Member
Registered: 2011-11-16
Posts: 780

Re: Swap on uncompressed ramdisk - useless?

Can you still hibernate your Laptop, when you don't have a Swap Partition the size of your RAM?

Offline

#9 2012-06-19 08:19:11

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: Swap on uncompressed ramdisk - useless?

blackout23 wrote:

Can you still hibernate your Laptop, when you don't have a Swap Partition the size of your RAM?

It depends, the contents of your RAM are compressed before being written to swap, but it's pretty hard to predict the worst case compression ratio that can be obtained.
I hibernate my machine regularly with a swap space being only 49% of my total RAM available and I never have had problems, but my RAM usage is never 100% when I hibernate either, although it typically is above 49% used (without caches and buffers which are dropped on hibernation).

Last edited by Ramses de Norre (2012-06-19 08:20:22)

Offline

#10 2012-06-21 05:41:16

Pajaro
Member
Registered: 2004-04-21
Posts: 875

Re: Swap on uncompressed ramdisk - useless?

Spacenick wrote:

This leads to the problem that when swap is used things crawl to a halt until the swap is full and the OOM killer shoots down a process (in newer kernels it really often finds that broken process and kills that first).
So you're just sitting there unable to do anything usefull until the culprit is killed.

I also never use swap because of this.

Offline

#11 2012-06-21 05:48:29

Awebb
Member
Registered: 2010-05-06
Posts: 4,131

Re: Swap on uncompressed ramdisk - useless?

This is called zRam, used to be called compcache. I'm not sure what I should need this for.

Offline

#12 2012-07-01 13:28:04

Xemertix
Member
Registered: 2009-04-09
Posts: 66

Re: Swap on uncompressed ramdisk - useless?

For me swap is useful: I have 3gb ram and 2gb swap (OCZ SSD),I can still use the system with a bit of lag with the swap almost full (fiefox opera with a lot of tabs,amule,thunderbird,amsn etc... with many days of uptime). HD swap would be deadly slow instead.

Offline

#13 2012-07-22 02:21:18

SiC
Member
From: Liverpool, England
Registered: 2008-01-10
Posts: 429

Re: Swap on uncompressed ramdisk - useless?

I have 16GB, which for some of the work I do isn't quite enough, if you make use of all the memory available to you, swapspace is invaluable.  My rule of thumb is twice as much swap as RAM, with half that being on a fast SSD.

I don't really understand why you would want to put swap onto a ramdisk though, it would surely be better to run with no swap and more main memory, unless I am missing something.  The kernel will make the best use of the resources available to it.

On a side note, use of ramdisk with swap and hibernation seems to me a recipe for disaster.

Offline

Board footer

Powered by FluxBB