XenialDog 64bit (Ubuntu 'Xenial Xerus' LTS, 64-bit)

A home for all kinds of Puppy related projects
Message
Author
wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#316 Post by wiak »

Oh, thanks dancytron, I just tried zramctl and it seems my system is actually just using lzo. Just reading the algorithm variable just said "[lzo] lz4"; I thought that meant lz4 was being used but zramctl suggests otherwise... So maybe I have to use that script you provided to fix that - but I'd rather somehow use zram-config; is there a simple way to make sure it uses lz4 that you know of?

wiak

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#317 Post by wiak »

Oh, thanks dancytron, I just tried zramctl and it seems my system is actually just using lzo. Just reading the algorithm variable just said "[lzo] lz4"; I thought that meant lz4 was being used but zramctl suggests otherwise... So maybe I have to use that script you provided to fix that - but I'd rather somehow use zram-config; is there a simple way to make sure it uses lz4 that you know of?

EDIT: Well that script you found seems to work anyway, but I'd still like zram-config method to work with lz4 out of the box - should surely be possible? (I don't want to also have to run the separate zram.sh script). I should study the scripts (zram.sh and also whatever is provided by zram-config, I suppose..., which may just be a matter of learning how to use that zramctl utility).

EDIT2: I tried:

Code: Select all

swapoff -a
zramctl -r /dev/zram0
zramctl -a lz4 -s 512M /dev/ram0
swapon /dev/zram0
But got error: swapon: /dev/zram0: read swap header failed

Not sure about the 512M or alternatively just tried 512000, but still get same error message. Clearly the answer will be in that script you found that I haven't studied yet...

okay, seems I had to again modprobe zram as in the zram.sh script and insert a mkswap command as also in that script - seems to be easier to use the script thus far, but I suspect there must be a startup script used by whatever comes with zram-config that could be modded to immediately provide lz4 rather than lzo, but I don't know how as yet. Any light shined on this would be appreciated.

wiak
Last edited by wiak on Sun 21 Jan 2018, 10:22, edited 1 time in total.

backi
Posts: 1922
Joined: Sun 27 Feb 2011, 22:00
Location: GERMANY

#318 Post by backi »

Hi everyone !

Let me try to explain what i observed .

Let me do it Step by Step .

Have a Swap-Partition on Harddrive .
I have installed zram-config via Synaptic .
Zram is automatically activated on Bootup.Also Swap-partition.

Installed (additionally) dancytrons Script in /usr/local/bin (made it executable )
Now my Observation .

After booting in Xenial Dog 32 Bit i disable Swap-Partition and disable(automaticallyl enabled Zram manually.
So Conky shows no Swap (zero) .

1. Enabling Zram with zram.sh start now shows 496 MiB Swap Space .
2. Disabling Zram with zram.sh stop now shows 0 MiB (Zero) Swap Space
3. Enabling Zram zram.sh start AGAIN now shows 744 MiB Swap Space ("almost" Double )

So what i mean :
BEFORE just using only zram-config installed with Synaptics ,it created a 496 Mib Swap-Space .
AFTER installing Dancytrons Script (additionally ) and executing Procedure above 1. 2. and 3.
Swap space increased to 744 MiB Swap Space .

Do not have any Idea what it means .Maybe the "NEW" Script is taking over /dominating the "OLD" one ?Who knows ?
Maybe somebody else will get a clue from that .

Regards !
Last edited by backi on Sun 21 Jan 2018, 12:12, edited 1 time in total.

backi
Posts: 1922
Joined: Sun 27 Feb 2011, 22:00
Location: GERMANY

#319 Post by backi »

Hi you guys !

https://wiki.debian.org/ZRam

The script which Dancytron posted .....i use it in DEBIAN DOGS since the Beginning .
Works flawless in Debian .Did not know it could work flawless in Ubuntu .......does it really ??????

Is Debian Dog (Stretch ,Jessie ) able to use lz4 ???Seems so if .....liblz4-tool is installed .
liblz4-tool is not installed by default .l

Xenial Dog there is also no liblz4-tool installed by default.


Searching Google for Zram lz4 compression found an interesting link :
https://starbeamrainbowlabs.com/blog/ar ... -zram.html

Some Thoughts on Zram and lz4 on the MX-Linux Forum :

https://mxlinux.org/forum/viewtopic.php?f=108&t=42935


Regards !
Last edited by backi on Sun 21 Jan 2018, 13:46, edited 2 times in total.

backi
Posts: 1922
Joined: Sun 27 Feb 2011, 22:00
Location: GERMANY

#320 Post by backi »

To open another Can of Worms :

Enable ZSwap to increase performance :

https://ubuntu-mate.community/t/enable- ... ance/11302
https://wiki.archlinux.org/index.php/Zswap


Should a separate Topic called "Using Zram----Zswap " be created ?

backi
Posts: 1922
Joined: Sun 27 Feb 2011, 22:00
Location: GERMANY

#321 Post by backi »

Hi you guys !

I am talking about Xenial Dog (32 bit )
After a lot of doubts I came to this conclusion :
So i did finally completely remove zram-config (formerly installed ) and its remnants :

It means :

removed :zram.config from /etc/inid
removed :zram from /etc/inid.d
removed :init-zram-swapping from /usr/bin
removed :end-zram-swapping from /usr/bin

Now was able to use your Dancytrons script without any conflicting/interfering Effects that came with zram-config formerly installed .

Doing zramctl in Terminal showed clearly lz4 is enabled when doing "zram.sh start" in Terminal .

root@xenial:~# zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4 743.8M 4K 64B 4K 1 [SWAP]
root@xenial:~#

Not quite sure if installing lz4-tool was necessary, which i did before .

For Debian i can not proof if lz4 is activated because command "zramctl" does not work in Debian ........maybe someone knows how to accomplish this in Debian Dog .

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#322 Post by wiak »

backi wrote:
Some Thoughts on Zram and lz4 on the MX-Linux Forum :

https://mxlinux.org/forum/viewtopic.php?f=108&t=42935

Regards !
Hi backi,

Coincidentally, and independently, I also came across a quick post on the mxlinux forum that suggested liblz4-tools was required so I had also yesterday installed that on my xenialdog64 system with zramconfig and rebooted. zramctl still however suggested lzo was being used rather than lz4 (the script dancytron found/provided did indeed however make zramctl indicate lz4 was being used - there is a line early on in that script which calculates the size of zram it provides). I would still like to find out how to achieve the same using zramconfig only - I read somewhere, I can't alas remember where, that it might be something to do with some other crypt software default - my quick check on that has revealed nothing so far. Also thought might be a zram config file for systemd that allows manual change from lzo to lz4 but haven't found that yet either. I'll unpack zramconfig deb package and see if I can find any clue in there if no one has 'the answer' or in the end, if can't otherwise find a zramconfig solution, also just use the zram.sh script. I'll report back of course if I find anything, which may take a while cos it is raining and my roof has been leaking so may have to work on things like that for a bit...

I also btw came across zswap alternative, but haven't looked into that yet (I think what I read said something had to be in the kernel for zswap to be used - maybe it already is - let us know if you try zswap and if it appears better in any way).

Though I'm mainly using a core II duo with 2 GB RAM, I'm also working on bringing my old Pentium M 1 GB RAM machine back to life (a Fujitsu Siemens Amilo M1424 - used to be 512MB but I upgraded it to 1GB) so will be using zram or similar with that. I also use xenialdog32 with that one (using forcepae kernel option).

cheers, wiak

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#323 Post by wiak »

Hi backi, dancytron,

Well I have now worked out one way how to get lz4 with zram-config. I extracted the deb and discovered:

/lib/systemd/system/zram-config.service

which contains:

Code: Select all

[Service]
ExecStart=/usr/bin/init-zram-swapping
ExecStop=/usr/bin/end-zram-swapping
...
I thus modified the /usr/bin/init-zram-swapping bash script to contain the indicated extra line (this is all that needs done to get zram lz4):

Code: Select all

# initialize the devices
for i in $(seq ${NRDEVICES}); do
  DEVNUMBER=$((i - 1))
  echo lz4 > /sys/block/zram${DEVNUMBER}/comp_algorithm  #wiak added
  echo $mem > /sys/block/zram${DEVNUMBER}/disksize
  mkswap /dev/zram${DEVNUMBER}
  swapon -p 5 /dev/zram${DEVNUMBER}
done
I thought all would be fine after that so, restarted that systemd service with:

Code: Select all

systemctl restart zram-config.service
EDIT: Fixed (I had put $i instead of ${DEVNUMBER} in first attemp...

zramctl now successfully gives:

Code: Select all

root@xenial64:~# zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4         466.7M   4K   65B    4K       1 [SWAP]
/dev/zram1 lz4         466.7M   4K   65B    4K       1 [SWAP]
wiak
Last edited by wiak on Mon 22 Jan 2018, 00:34, edited 1 time in total.

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#324 Post by dancytron »

Try "{DEVNUMBER}" in place of "i"?

edit: You fixed it while I was posting.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#325 Post by wiak »

Posts crossed dancytron - I had already done that and edited my above post. hahaha so many crossed posts! ;-)

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#326 Post by wiak »

By the way, if you want to increase the percentage of RAM used for zram swap to the same as the lz4-modded debian script dancytron provided, inside bash shell script /usr/bin/init-zram-swapping you can change the line:

Code: Select all

mem=$(((totalmem / 2 / ${NRDEVICES}) * 1024))
to:

Code: Select all

mem=$(((totalmem * 75 / 100 / ${NRDEVICES}) * 1024))
or make similar calculation mods for smaller or larger zram swap sizes.

Of course there is a limit as to how much actual RAM it is good to allocate to zram (since your system will run out of physical RAM and start using zram when it otherwise wouldn't and so on...). I'd stick with the lower zram amount you find you actually need to help avoid as much swapping as possible anyway.

wiak
Last edited by wiak on Mon 22 Jan 2018, 01:14, edited 1 time in total.

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#327 Post by dancytron »

1.8 Gig Intell Dual Core, 3 Gig of Ram.

Seems to work.

Before, if I hit a bad webpage that leaked ram (or just had a ridiculous amount of stuff running)and it started to swap, that was it. I wrote a little "kill chrome and firefox" script, and if I could run it before it froze completely, then in about 5 minutes I could have my computer back, otherwise it was a hard shutdown.

To test, I opened Firefox 57 and opened about 20 tabs with lots of video and other crap and got it to start swapping. Then I opened up another Firefox, opened up about 8 more tabs, including CBSN live news. Conky shows mem at 88% 2.6 GiB and swap at 35% 810 MB. CBSN is playing fine. I am posting from it now. It has hiccuped a few times and is slower than normal, but it seems stable.

A big improvement. Now swapping 51%.

p.s. Just to be clear, I am running DD 64 Stretch, not Xenial Dog, but it seems more or less the same.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#328 Post by wiak »

dancytron wrote:I wrote a little "kill chrome and firefox" script, and if I could run it before it froze completely, then in about 5 minutes I could have my computer back, otherwise it was a hard shutdown.
Yes, major headache - I do similar. XenialDog32 (but not xenialdog64) actually comes by default allowing ctrl-alt-backspace to drop down to commandline if done quickly enough on browser freeze - then startx to get desktop back. But kill script better option for such occurrence probably.

wiak

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#329 Post by dancytron »

wiak wrote:
dancytron wrote:I wrote a little "kill chrome and firefox" script, and if I could run it before it froze completely, then in about 5 minutes I could have my computer back, otherwise it was a hard shutdown.
Yes, major headache - I do similar. XenialDog32 (but not xenialdog64) actually comes by default allowing ctrl-alt-backspace to drop down to commandline if done quickly enough on browser freeze - then startx to get desktop back. But kill script better option for such occurrence probably.

wiak
If this zram thing works as well as it seems to, then I think those days are past.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#330 Post by wiak »

No, I've been using zram for a while but still occasional browser freezes (chrome sometimes for me) despite not many tabs open! I test zram browser use via opening multiple gmail tabs (since each such tab seems to use a consistent RAM amount and quite a lot of it) and monitor free and available RAM via top running in an always on top window. But yes, browser freeze is certainly very rare now with zram running on my system.

wiak

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#331 Post by wiak »

I maybe should mention that I tend to manage about 12 open gmail tabs with latest firefox on my 2GB RAM machine when using 1GB zram swap. One other method (quickest!) to save from the browser freeze/crash issue is to immediately close a busy tab or two as soon as mouse slowdown is noticed...

wiak

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#332 Post by wiak »

I still haven't tried zswap on my xenialdog, but though it has disadvantage that it also needs actual swap space allocated it has advantage that the first pages paged out of swap will be the Least Recently Used, whereas most recently used would be better (in my understanding at least). Nice post about zswap performance (much of which might apply to zram) here:

https://www.ibm.com/developerworks/comm ... y7?lang=en

But also from that post the comments section is very interesting.

I guess we just have to suck them and see (i.e. try them both out).

Note that you can also use a zram like any other block device. For example you don't need to use it for swap - you can make a filesystem (mkfs) on it and use as a temporary disc in ram.

wiak

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#333 Post by wiak »

Doing some experiments...

Code: Select all

root@xenial64:~# dmesg | grep zswap
[    0.000000] Command line: noauto from=/xenial64/ changes=EXIT:/xenial64/casper/ zswap.enabled=1 zswap.compressor=lz4
[    0.000000] Kernel command line: noauto from=/xenial64/ changes=EXIT:/xenial64/casper/ zswap.enabled=1 zswap.compressor=lz4
[    3.759855] zswap: compressor lz4 not available, using default lzo
[    3.759911] zswap: loaded using pool lzo/zbud
root@xenial64:~# free
              total        used        free      shared  buff/cache   available
Mem:        1911492       95460     1400088       38080      415944     1608912
Swap:        955744           0      955744
Note how to enable zswap on kernel line of grub4dos menu.lst from above dmesg output. I don't have any other 'actual' swap except zram. I'm wondering how this goes - I'm presuming zram won't be used till zswap compressed cache area filled and maybe Most Recent In First Out will work in stead of zram Last In First Out.

EDIT: Of course, for more conventional zswap use (or combined for experiments with zram) I could create and activate a swap file like the following (also could effectively create it in RAM on Porteus changes folder boot machine by creating it in /root or similar...):

Code: Select all

dd if=/dev/zero of=/mnt/home/swapfile0 bs=1024 count=256k
# could also use 'fallocate -l 256M /mnt/home/swapfile0' command but only works on some filesystem types
chmod 600 /mnt/home/swapfile0
ls -lh /mnt/home/swapfile0 # to check creation size
mkswap /mnt/home/swapfile0
swapon /mnt/home/swapfile0
EDIT: Short answer is that mixing zram with zswap doesn't work so well cos both are taking RAM space (once swapping occurs) but zswap itself isn't actually contributing any additional swap space (unless a swap file or partition is also being used out of RAM, whereupon it might work well, assuming I reduce zram amount proportionally - to be tested...)

Anyway, sorry Fred, this stuff definitely needs thread of its own now...

wiak

belham2
Posts: 1715
Joined: Mon 15 Aug 2016, 22:47

#334 Post by belham2 »

Hi all,

Question: do either zram and/or zswap apply to people who are running more than, say, 1GB of RAM?

Reason I ask, is that I have both desktop machines and laptops I use, and when I go through & do everything to have either zram and/or zswap, I cannot tell one bit of "performance"or "speed" or "efficiency" differences (doing heavy loaded browser tests---multiple tabs and even multiple browsers open) on any of my machines. Even my Atom Intel netbook, with 2GB of RAM and that punk little atom processor, shows very little performance increase (less than 2-3%). And on my 8GB & 16GB RAM machines with old Athlon X2 processors & 7-10 yr old motherboards, there is "zero" performance and "speed" increase.

I've come to the conclusion this zram/zswap benefit is all in our heads, and both zram/zswap are not worth anything. What makes me even more suspicious is the talk on the zram/zswap wiki pages of..well, you know people, listen to us, our zram/zswap will "at least" give longer life (in terms of writes) to your USB and/or SSD drives. That stuff is marketing 101 bullsh!t, every one in the Linuzx industry has known that for years.

Please, I know this is contrary to what some of you say you are seeing with zram/zswap enabled, but I honestly just don't get it. How do you know for sure, other than non-technical "observation" tests now being performed, that zram/zswap is effective. Answer? You don't know for sure, unless you can dis-assemble a kernel (along with the hardware) and test each component individually with zram/zswap enabled vs dis-abled. Linux Torvalds & others debunked this a few years ago concerning zram/zswap.

Another additional observation: if zram and zswap were so effective, why is "neither of them" included in any other linux distro that I know of except for Lubuntu? And even Lubuntu's developers (of which I follow) are talking about abandoning it because it is a "solution" looking for problems that don't exist.

It is my belief to much time is wasted on stuff like this, but hey, what do I know, I am just a lowly user with absolute zero skills, lol.

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#335 Post by wiak »

belham,

You obviously haven't tried browser load tests (e.g. load multiple tabs with heavy use webpages such as gmail). Browsers such as Chrome or Firefox will crash on 2GB RAM machine with as little as 8 such tabs open. They manage around 12 such tabs open on my machine with zram-config installed. These are not just 'observations' - the memory versus swap-consumed are measurable via top command amongst others. Such work is my profession. It is not about performance increase - it is about more virtual RAM without so much loss of performance conventional swap file or partition would result in.

EDIT: By the way, since zram provides a block device you could also configure it to provide compressed /tmp filesystem, which could also be handy since gives a larger /tmp in RAM filesystem. Maybe even a compressed /mnt/live/memory/changes filesystem... could be very handy for certain types of development work.

wiak
Last edited by wiak on Mon 22 Jan 2018, 08:54, edited 1 time in total.

Post Reply