Author Topic: 'Suspend to RAM' function: minimum swapsize required for implementation?  (Read 2915 times)

Offline vc

  • Hero Member
  • *****
  • Posts: 519
The 'Suspend to RAM' function intrigues me a bit - how well/reliably does it function, and what would be the minimum swapsize required to implement it properly?  The machine in question would be a model 701 EeePC, with 2GB of RAM, the stock onboard 4GB SSD, and a 16GB SDHC card permanently plugged into its cardreader.  The intent would be to place the /swap partition on the SDHC card (for ultimate replaceability), and to set swappiness to 'never', accordingly.  Feasible?

Offline Rudge

  • Hero Member
  • *****
  • Posts: 9772
  • I'm Just A Dog.
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #1 on: January 20, 2010, 10:00:47 PM »
vc, you keep us on our toes hu?  ;)

Why don't you try it out and let us know.   ;D


-If you wish to make an apple pie from scratch, you must first invent the universe-  Carl Sagan

Offline vc

  • Hero Member
  • *****
  • Posts: 519
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #2 on: January 20, 2010, 10:50:18 PM »
vc, you keep us on our toes hu?  ;)

Why don't you try it out and let us know.   ;D

Rudge, I do wish to give it a go - all I'm asking for is a small amount of prerequisite information, specifically:

1)  Is it worth it?  Have there been any instances of serious issues or problems with it?  and

2)  What size of swap partition would I need to create?  Must it match the memsize, or be made larger, or is there perhaps some compression involved?

That's all, thank-you.  As for keeping you folks "on your toes", well... I certainly do not intend to be annoying or disruptive; I simply happen to have a head full of offbeat questions, so I pose them.  I do remain hopeful that against all odds, eventually some day I may actually learn something amidst all the furor and groans.  More importantly though; do my questions not coincidentally serve the curiosities of at least a few others?  Or is my head really stuck 'way too far out in the ozone for such to occur?

At any rate, I do remain appreciative, regardless.  Ulcers notwithstanding, today has been one of the best days I've yet experienced on this forum!   :-)
« Last Edit: January 21, 2010, 12:01:38 AM by vc »

Offline 7272andy

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1624
  • UK MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #3 on: January 21, 2010, 03:20:36 AM »
Hi guys, on my lappy I have the swap set to 4GB (twice the installed ram) and have no problems with suspend, hibernate or recover even while video editing and transcoding.

You can suspend without swap, but you need swap=ram (at a minimum) to hibernate because the hibernate file is saved to swap. You may need MORE swap than ram if you hibernate at a state where your swap is already heavily used for swapping.
But you don't need swap to suspend


Bare Metal 1         Bare Metal 2
Intel Celeron 420M   Intel i5 540M
2GB Ram              4GB Ram
Intel 943GM          Radeon HD 5650 PCI Express
RT2573               RT2790
32bit KDE            32&64bit KDE

Offline Rudge

  • Hero Member
  • *****
  • Posts: 9772
  • I'm Just A Dog.
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #4 on: January 21, 2010, 08:57:33 AM »
vc, you keep us on our toes hu?  ;)

Why don't you try it out and let us know.   ;D

Rudge, I do wish to give it a go - all I'm asking for is a small amount of prerequisite information, specifically:

1)  Is it worth it?  Have there been any instances of serious issues or problems with it?  and

2)  What size of swap partition would I need to create?  Must it match the memsize, or be made larger, or is there perhaps some compression involved?

That's all, thank-you.  As for keeping you folks "on your toes", well... I certainly do not intend to be annoying or disruptive; I simply happen to have a head full of offbeat questions, so I pose them.  I do remain hopeful that against all odds, eventually some day I may actually learn something amidst all the furor and groans.  More importantly though; do my questions not coincidentally serve the curiosities of at least a few others?  Or is my head really stuck 'way too far out in the ozone for such to occur?

At any rate, I do remain appreciative, regardless.  Ulcers notwithstanding, today has been one of the best days I've yet experienced on this forum!   :-)

vc, I joke a lot so ignore me whenever possible  ;D


-If you wish to make an apple pie from scratch, you must first invent the universe-  Carl Sagan

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #5 on: January 21, 2010, 10:19:04 AM »
I remember reading a post which said that the Swap needed to be about 2 x the size of RAM (or maybe a little more) to use suspend to disc.
I would think that suspend to RAM would not need any Swap ......  but I have not tried it ...... logically why would swap be needed if working in RAM only?
Of course I have no idea how much RAM one would need to suspend PCLOS to RAM .............

...... so essentially this post was a waste of time   :D ..... but maybe it caused some questions  .......   ;)

Offline vc

  • Hero Member
  • *****
  • Posts: 519
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #6 on: January 21, 2010, 05:20:45 PM »
Questions, eh?  Well, here's one:  why Suspend to RAM, anyway?  I thought the idea behind Suspend was to first freeze the system, and then suspend the current state to an imagefile, so that when you turned the machine back on again it could read said imagefile, restore the previous state, and resume system operation from the same point where it had previously been suspended.  Suspend to RAM doesn't make sense to me, because as soon as the machine turns off that RAM is erased anyway - so what would be the point?

<Modify>

Okay, so here's my ulterior concerns:

1)  In the four or five years that I have been struggling, I have always selected either Restart or Shutdown.  I never reboot or shut down any other way, unless the entire system has frozen or somelike.

2)  This attempt would be performed upon an EeePC, so I must be concerned with issues of both drivespace and write-cycling.  My initial consideration suggested a 2.05GB primary /swap partition on /dev/sdb1 (first partition on the 16GB SDHC card), as this configuration would be bearable relative to the cardsize.  4.05GB would certainly be onerous; I don't wish to devote that much to such - I'd sooner search for a way to get rid of the 'Suspend to RAM' entry in the Menu, instead.
« Last Edit: January 21, 2010, 05:36:39 PM by vc »

Offline 7272andy

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1624
  • UK MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #7 on: January 22, 2010, 03:20:00 AM »
I remember reading a post which said that the Swap needed to be about 2 x the size of RAM (or maybe a little more) to use suspend to disc.

The swap is 2 x ram rule is an old concept that harkens back to the time when ram was very expensive and the performance hit taken when using swap was considered an  acceptable trade off for the cost of the hardware.

Questions, eh?  Well, here's one:  why Suspend to RAM, anyway?  I thought the idea behind Suspend was to first freeze the system, and then suspend the current state to an imagefile, so that when you turned the machine back on again it could read said imagefile, restore the previous state, and resume system operation from the same point where it had previously been suspended.  Suspend to RAM doesn't make sense to me, because as soon as the machine turns off that RAM is erased anyway - so what would be the point?

Suspend to ram (also known as sleep) has no need for swap; all open applications and active files are held in RAM and the machine then enters a very low power state (5 watts or so), the main purpose being to ensure the RAM is kept powered thus preserving the machine state (note the system is not powered off). this allows the machine to be woken up and used very quickly without having to wait for the full boot process. It is only really used on desktop systems or for short periods on laptops, as you point out, if you lose power you lose anything unsaved and possibly cause file damage.

Suspend to disk (also known as hibernate), is a very similar process, the difference being that an image of the above state is is saved to swap and the machine is then powered off.

From this it can be seen that the swap needs to be at least as large as ram. If you find that you use the swap when performing memory intensive tasks on the machine (such as video or audio work), and you intend to use suspend to disk, then you should configure your swap file to at least equal the peak swap usage plus the installed RAM

As you're using an eeepc and not concerned about Hibernating the machine I would suggest you monitor your swap usage (use free -t in a shell window), and if you don't use it remove it, or reduce it to a level you are happy with. If this is a new build you are contemplating, start with swap = RAM with a view to reducing it if it is not used.

Regards
Andy


Bare Metal 1         Bare Metal 2
Intel Celeron 420M   Intel i5 540M
2GB Ram              4GB Ram
Intel 943GM          Radeon HD 5650 PCI Express
RT2573               RT2790
32bit KDE            32&64bit KDE

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #8 on: January 22, 2010, 03:27:00 AM »
I remember reading a post which said that the Swap needed to be about 2 x the size of RAM (or maybe a little more) to use suspend to disc.

The swap is 2 x ram rule is an old concept that harkens back to the time when ram was very expensive and the performance hit taken when using swap was considered an  acceptable trade off for the cost of the hardware.


Not quite -- if I am remembering the explanation correctly ......... it went something like ........ the contents of the RAM are cached in Swap and from there are prepared for suspend, so the Swap space needs to be capable of holding almost twice the contents of the RAM. Should Swap be in use at the time then that also has to be factored in.

I am not making any pronouncement on the matter, just trying to recall what I read about the process .... and it was on this forum some time ago that I read it.   ;)


EDIT
          Although a running system is capable of using many Swap partitions - for instance each Swap partition on each disk in the system could be available to the running system - this is no good for suspend to disk. One single Swap space must be capable of accommodating everything, as it is apparently incapable of being stored to, and resumed from, more than the one Swap space.




regards.
« Last Edit: January 22, 2010, 03:37:24 AM by JohnBoy »

Offline 7272andy

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1624
  • UK MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #9 on: January 22, 2010, 04:07:06 AM »
JohnBoy, I remember reading the same thing, I think it was around 2007 when davecs was writing his howto.

For me I've 2GB RAM and 3GB swap (though I may reduce this further), my swap only gets hit when I'm working on video editing and transcoding and/or have virtual machines running; even then it's nowhere near a gig used and hibernate behaves as expected.

Of course I could just be lucky with my hardware  :D :D

Regarding your edit, it's a very good point, and one that I had completely forgotten about.

It's at times like this I wish we still had the old forum posts available.

Regards
Andy


Bare Metal 1         Bare Metal 2
Intel Celeron 420M   Intel i5 540M
2GB Ram              4GB Ram
Intel 943GM          Radeon HD 5650 PCI Express
RT2573               RT2790
32bit KDE            32&64bit KDE

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #10 on: January 22, 2010, 05:41:00 AM »
Andy,
           if you attempt to suspend to disk while all of your RAM is being used then that may throw up a problem -- if what I am remembering is correct.
In normal circumstances of course less than 1GB of ram will be in use and suspend should give no problems.
I think it may have been a post from Ike that I am recalling ........  not sure  .....   

Offline 7272andy

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1624
  • UK MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #11 on: January 22, 2010, 06:28:30 AM »
Now there's a name from the past, I wonder how he's doing.

Out of interest I just hibernated, resumed, suspended and resumed while transcoding an old video file with no problems. But, I guess the kicker was, nothing had swapped and I still had 50MB Physical Memory free.

It's a pity we can't get something definitive on this (not that I'm denigrating your memory in any way, or my experiments)

EDIT
This article is pretty interesting, seems to bear out your memory rather than my experiences though  :D

Cheers JohnBoy

Regards
Andy
« Last Edit: January 22, 2010, 06:45:42 AM by 7272andy »


Bare Metal 1         Bare Metal 2
Intel Celeron 420M   Intel i5 540M
2GB Ram              4GB Ram
Intel 943GM          Radeon HD 5650 PCI Express
RT2573               RT2790
32bit KDE            32&64bit KDE

Offline j-retired

  • Hero Member
  • *****
  • Posts: 984
  • To find out what 'busy' is, then try retiring!
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #12 on: January 22, 2010, 07:48:42 AM »
On my Acer Aspire One I have tried running with no swap file at all, and it seems to work quite well, though I don't use it for anything intensive.  Every time I have tried 'hibernate' or 'suspend' it has been a bit unreliable - most of the time it would work...... and then! And this is with several different machines.

j

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6849
  • MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #13 on: January 22, 2010, 07:52:58 AM »
Hehe ....... I would not depend on my memory for anything as critical as this!      ;D ;D

Thanks for the link.
Like a lot of things we can get away with a minimum but when the load really comes on something can go amiss and data corruption results.

I think I will stick to 2 x RAM plus a little more, for those machines that just might suspend to disk, and all that Swap space must be in one contiguous block.

For others with lots of memory, maybe a 0.5GB Swap would be sufficient -- 'just in case', and if it is discovered that more is needed then a second Swap space can be created. The OS will use both.

When dealing with data integrity I believe it is best to err on the side of caution rather than have the absolute minimum calculated as sufficient. As a persons use of their machine changes over time 2 x RAM seems a good safe amount. Of course, just to confuse things further, people regularly increase the amount of RAM fitted, and if also using suspend to disk, then a new Swap space would have to be created to equate to 2 x RAM.  :D

All great fun!   ;D ;D ;D
« Last Edit: January 22, 2010, 07:54:56 AM by JohnBoy »

Offline 7272andy

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1624
  • UK MLU
Re: 'Suspend to RAM' function: minimum swapsize required for implementation?
« Reply #14 on: January 22, 2010, 08:15:02 AM »
Having just spent a couple of hours roaming around the net, filtered for this year and last (as far as possible). The definitive answer seems to be "it depends" ::).

Advocates seem to exist in equal numbers for;
  • no swap, add more ram
  • Swap should never be greater than 2GB
  • Swap should equal Ram
  • Swap should be Ram + video memory
  • Swap should be 1.5 x Ram
  • Swap should be 2 x Ram

no wonder folk get confused :D.

One thing I did notice was that most of the netbook owners (who posted) run without swap in an attempt to reduce writes to the SSD, there were plenty of arguments as to the effectiveness of this strategy though.

Regards
Andy
« Last Edit: January 22, 2010, 08:47:51 AM by 7272andy »


Bare Metal 1         Bare Metal 2
Intel Celeron 420M   Intel i5 540M
2GB Ram              4GB Ram
Intel 943GM          Radeon HD 5650 PCI Express
RT2573               RT2790
32bit KDE            32&64bit KDE