Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 23 Jun 2018, 04:59
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
zram and zswap
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [19 Posts]   Goto page: Previous 1, 2
Author Message
wiak

Joined: 11 Dec 2007
Posts: 857
Location: not Bulgaria

PostPosted: Fri 04 May 2018, 00:04    Post subject:  

bigpup wrote:
Quote:
Furthermore, if you are using such as a usb-flashstick, using zram for swap does not require continual data writes to the flash device, which helps it last longer
.
Is this working the same as the ram disk that Puppy uses when running from a USB flash drive?


In short, no. The description ram-DISK (which is nothing to do with zram) basically indicates that a portion of RAM is being used to store programs (as they would be on a disc such as hard drive or cd or dvd or flashdrive, for example). That pseudo-disc stored in RAM is obviously using up some of the RAM for pure 'storage' purposes, but of course some RAM has to be kept left over because actually running a program requires it to be loaded (and uncompressed) into RAM so it can be executed. Problem is big programs executing from RAM may end up wanting more space than RAM is available. Traditional way out of that is to have what is called swap space on external (non-RAM) storage - then VIRTUAL RAM is the size of (total RAM - any ramdisc size) + size_of_swap_space. You probably know that Virtual RAM works by swapping out some actual active executing programs (when they are not actively running) into the swap-space and then loading them back in again when CPU wants to execute them (this is a slight simplification of the process of course). Trouble is the swapping-out and swapping-in process from RAM to external storage is SLOW...

zram is a clever trick, where a portion of the 'free non-Virtual RAM' (i.e. actual RAM) is used as an in-RAM swap space. At first sight that idea seems ridiculous because clearly that zram swap space is using some actual RAM, which would appear to defeat its purpose. However, the 'trick' is that the programs swapped into that zram area are automatically COMPRESSED. The total Virtual RAM will be whatever (actual RAM remains + the zram data-compressing space), which is same formula as conventional swap space. But the difference it that the zram data is highly compressed so effectively Virtual RAM is much bigger since effectively = actual RAM + (zram-size x compression factor), and it's fast cos really it is all in actual RAM (so fast access). So end advantage of using zram is that yes, actual non-zram-swap RAM will be less since some used for zram swap, but the zram swap, being compressed is like having part of the actual RAM magnified in size (without disadvantage of slow access to external storage swap).

Yes, decompression does take CPU cycles (time) but generally that decompression is done much faster than external storage access would have taken.

bigpup wrote:

Does this conflict with proper operation of the Puppy ram disk?
How Puppy works:
http://bkhome.org/archive/puppylinux/development/howpuppyworks.html


No. It's a separate thing. Puppy's methodology, uses some RAM, including simply storing programs inside a pseudo storage disc in RAM (ramdisk), which can certainly be accessed fast since in RAM (but still has to be copied into other part of RAM for actual instruction execution since ramdisk is acting like a storage disc, not like RAM, if you see what I mean...); what is left can be divided into RAM + zram-swap per above description, which gives a much larger overall VIRTUAL RAM in which instructions are (effecively) actually executed (albeit via page swapping in and out of the fast effectively size-magnified compressed RAM-based swap space).

Unfortunately, I've seen comments dismissing zram as not-working, which reveals they have never actually tested its operation. Of course it magnifies effective Virtual RAM memory, which means you can run more processes before machine runs out of virtual RAM space (after which it would crash...). You can test that from a webbrowser by loading memory-hungry pages such as gmail or facebook and opening more and more tabs of these till crash inevitably happens - you will find you can open more such tabs with zram enabled. You can also monitor RAM usage in either 'free' or 'top' utility and see the RAM+zram-swap actually running out. And using zram-swap is MUCH faster than when external slow storage space swap is being used, so it is a win win situation, but of course if you want to run even more processes you also need to have external storage swap, but zram-swap will be used first (once external swap actually starts being used you would notice your system slowing down........ but at least would help prevent actual system crash/freeze...).

wiak
Back to top
View user's profile Send private message 
rufwoof

Joined: 24 Feb 2014
Posts: 2368

PostPosted: Fri 04 May 2018, 13:10    Post subject:  

wiak wrote:
Yes, decompression does take CPU cycles (time) but generally that decompression is done much faster than external storage access would have taken.

The likes of lz4 decompression approaches ram bus speeds such that you can actually achieve the benefits of in effect doubling up the capacity (assuming 2:1 average compression ratio) without sacrificing speed - at least on the read side (write is slower, but still very quick for lz4 compared to many of the alternatives).

Personally I don't run with swap as for one that leaves fingerprints that could potentially be read. For another ... if you start filling up swap especially in the case of the 'average' PC and relative size of most Puppies, likely that would continue (run-away process) anyway and once swap fills the system pretty much locks up the exact same as if there'd been no swap anyway i.e. grinds to a near halt (but just a little sooner without swap compared to if there was swap) such that you have to hard-reset. The exception being if you run large programs/activities such as video editing etc, in which case I just create a swap file interactively for that task. Swap IMO is more appropriate for multi-user server type setups (or if you're running very old hardware with small amounts of ram - when generally the interaction would be too slow for comfort anyway).
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 1082

PostPosted: Fri 04 May 2018, 14:48    Post subject:  

Can I use zram with swap? So that if I run out of zram then my zram will use swap?
Back to top
View user's profile Send private message 
dancytron

Joined: 18 Jul 2012
Posts: 1064

PostPosted: Fri 04 May 2018, 17:27    Post subject:  

s243a wrote:
Can I use zram with swap? So that if I run out of zram then my zram will use swap?


Yes. You'll need to check the priority so that it swaps to zram first and then to your regular swap file. Not sure how to change it since mine seems to work out correctly by default, but to check it:

Code:
root@live:~# swapon -s
Filename                             Type         Size      Used    Priority
/dev/sda3                                 partition   1430524   0   -1
/dev/zram0                                partition   1152164   0   10
/dev/zram1                                partition   1152164   0   10
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 2 [19 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0532s ][ Queries: 14 (0.0093s) ][ GZIP on ]