# zswap - is it always worth it?

## ATpwwu

Because it's so simple to turn off and on I decided to try it, While copying files from one hard drive (ntfs) to another (btrfs, lzo compression) and defraging compressing a third (also btrfs and lzo) and surfing the web.

Without zswap cpu usage was around 50% and kde ran smoothyl

Witzh zswap cpu usage was 80% and everything  was stuttering.

Specs i5 4460, 16gb ram, main drive (wasn't  really in use) samsung evo 840 500gb with 16 gb swap (I call bullshit on the whole swap on ssd issue), ntfs drive WDC WD7500BPVX-00JC3T0 (some sort of 2.5 inch laptop drive), other two WDC WD30EFRX-68EUZN0 (wd 3tb red model)

----------

## Keruskerfuerst

Zswap compresses the data written to swap with lzo.

I would not use it.

----------

## ATpwwu

It's just one echo to enable and I was bored and wanted to see what would happen  :Smile: 

But there's something more going on here, if I'm copying a file why should't even work way.  it shouold not even touc any cache, just be streamed from one device do the other with dedicated he oh board do t it go o ram o ram. Tue CPU should just teoo dev9ce 1 c90s ahd cijoress cecrors,ssed and writen? s

----------

## davidm

 *ATpwwu wrote:*   

> dedicated he oh board do t it go o ram o ram. Tue CPU should just teoo dev9ce 1 c90s ahd cijoress cecrors,ssed and writen? s

 

???

----------

## Roman_Gruber

Summary.

check with top / htop how much ram you really need. =>>> get rid of 16gb swap partition, it is not needed at all

stick to proven file systems like ext4 => do not use btrfs, when you are an "inexpierenced user" => some call them "noobs"

Very bad: swap partition on SSD will make your Drive fail much faster, and you will loose warranty because of the write cycles. And I assume your data is also on that ssd, you will expierence full data loss. 

Hint => backups are your friend.

----------

## Ant P.

zswap is single-threaded by default; you need to pass $(nproc) to your zramctl command for decent performance.

----------

## mv

 *Ant P. wrote:*   

> zramctl command

 

zram != zswap

----------

## user

I don't use zswap, I use zram for compressed swapped pages in memory still.

I have sufficient ECC memory to _not_ write (compressed) swapped pages to physical disc.

```
# cat /etc/udev/rules.d/10-zram.rules 

KERNEL=="zram0", SUBSYSTEM=="block", DRIVER=="", ACTION=="add", ATTR{initstate}=="0", ATTR{comp_algorithm}="lz4", ATTR{disksize}="512M", RUN+="/sbin/mkswap $env{DEVNAME}"

KERNEL=="zram1", SUBSYSTEM=="block", DRIVER=="", ACTION=="add", ATTR{initstate}=="0", ATTR{comp_algorithm}="lz4", ATTR{disksize}="512M", RUN+="/sbin/mkswap $env{DEVNAME}"

KERNEL=="zram2", SUBSYSTEM=="block", DRIVER=="", ACTION=="add", ATTR{initstate}=="0", ATTR{comp_algorithm}="lz4", ATTR{disksize}="512M", RUN+="/sbin/mkswap $env{DEVNAME}"

KERNEL=="zram3", SUBSYSTEM=="block", DRIVER=="", ACTION=="add", ATTR{initstate}=="0", ATTR{comp_algorithm}="lz4", ATTR{disksize}="512M", RUN+="/sbin/mkswap $env{DEVNAME}"

# swapon -s

Filename                                Type            Size    Used    Priority

/dev/zram0                              partition       524284  188136  16383

/dev/zram1                              partition       524284  187732  16383

/dev/zram2                              partition       524284  187968  16383

/dev/zram3                              partition       524284  187852  16383

# zramctl 

NAME       ALGORITHM DISKSIZE   DATA  COMPR TOTAL STREAMS MOUNTPOINT

/dev/zram0 lz4           512M 159.5M  85.9M   92M       1 [SWAP]

/dev/zram1 lz4           512M   159M  85.4M 91.2M       1 [SWAP]

/dev/zram2 lz4           512M 159.3M  85.6M 91.5M       1 [SWAP]

/dev/zram3 lz4           512M 159.2M  85.4M   91M       1 [SWAP]

```

----------

## ATpwwu

 *tw04l124 wrote:*   

> Summary.
> 
> check with top / htop how much ram you really need. =>>> get rid of 16gb swap partition, it is not needed at all
> 
> stick to proven file systems like ext4 => do not use btrfs, when you are an "inexpierenced user" => some call them "noobs"
> ...

 

I have more backups than brains (srs, anything important is on at least 4+ devices in separate locations, anything not important is probably still backuped once. Learned that lesson a long time ago.

Uh, I've used gentoo on multiple pcs between 2005, to 2012-3 when a series of hw failures made me switch to windows because.... idk just because.. wanted to see how the other side was. Then I had a really nice laptop die about 1 year ago and was forced to use win 8.1 (and later win 10) a tablet with 2GB ram and some shitty emmc (really, why do they cripple these things with so little ram and bad io.... if the thing had 4-8gb and a real ssd (nothing  big, 250gb would have been plenty the z3775 cpu couldn't look half as bad.. in cpu limited situations it was about as fast as an ivy bridge i3 running at the same frequency). Not to mention the dozens of vpses I ran. I may be a lot of things (alcoholic maybe sine one of the hw faliures was caused by me spilling a bottle of rum on a laptop), but I'm not a noob.

 *Quote:*   

> dedicated he oh board do t it go o ram o ram. Tue CPU should just teoo dev9ce 1 c90s ahd cijoress cecrors,ssed and writen? s

 eat a bunch of xanax (well actually it was desmethylflunitrazepam but nobody would kwnow what that it..... i think it was about the equivalent of 20mg xanax) and write a coherent post  :Smile: 

----------

## kernelOfTruth

Naturally zswap should only affect anything if you're using swap (zswap) - otherwise you

could go with a few gigs of zram,

zswap also supports lz4 compression with should be more efficient.

Not sure about your usage pattern but usually I don't need swap at all or only a few MiB are taken so the effect on system responsiveness here is very very low,

with the previous system and 8 GiB swap was used more often but the effect also wasn't that bad with zswap

I guess it depends how up-to-date your kernel and system (software side) are and what else works in the background during this stress test

 *ATpwwu wrote:*   

> 
> 
>  *Quote:*   dedicated he oh board do t it go o ram o ram. Tue CPU should just teoo dev9ce 1 c90s ahd cijoress cecrors,ssed and writen? s eat a bunch of xanax (well actually it was desmethylflunitrazepam but nobody would kwnow what that it..... i think it was about the equivalent of 20mg xanax) and write a coherent post 

 

Wow - that bad ?   :Shocked: 

Was once in a situation I wanted to go that route but got disadvised (one among them a pharmacologist who also had taken it and said that it had quite an effect on thinking-ability) from several people to avoid doing so   :Surprised: 

----------

