[Solved] zswap or zram? Which one to use in debian 12 with KDE Plasma

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
GroudonandKyogre
Posts: 55
Joined: 2024-11-27 09:35
Has thanked: 1 time
Been thanked: 1 time

[Solved] zswap or zram? Which one to use in debian 12 with KDE Plasma

#1 Post by GroudonandKyogre »

Hi, I was scrolling through the debian wiki and suddenly found out about zram and zswap. I have an 8gb swap partition (recommended size by the linux community when I used to have 3gb ram). I was just wondering if I should stick with zswap or use zram OR both. Will there be any performance improvement when using both? If not, then which one should I use?
output of inxi -Fxxxxz

Code: Select all

ak@debian:~$ inxi -Fxxxxz
System:
  Kernel: 6.1.0-30-amd64 arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    Desktop: KDE Plasma v: 5.27.5 tk: Qt v: 5.15.8 wm: kwin_x11 vt: 7 dm: SDDM
    Distro: Debian GNU/Linux 12 (bookworm)
Machine:
  Type: Desktop Mobo: Gigabyte model: G31M-ES2L serial: <superuser required>
    BIOS: Award v: FI date: 08/09/2010
CPU:
  Info: quad core model: Intel Core2 Quad Q9550 bits: 64 type: MCP
    smt: <unsupported> arch: Penryn rev: A cache: L1: 256 KiB L2: 12 MiB
  Speed (MHz): avg: 2833 min/max: N/A cores: 1: 2833 2: 2833 3: 2833 4: 2833
    bogomips: 22665
  Flags: ht lm nx pae sse sse2 sse3 sse4_1 ssse3
Graphics:
  Device-1: NVIDIA GK107 [GeForce GT 740] driver: nvidia v: 470.256.02
    arch: Kepler pcie: speed: 2.5 GT/s lanes: 16 bus-ID: 01:00.0
    chip-ID: 10de:0fc8 class-ID: 0300
  Display: x11 server: X.Org v: 1.21.1.7 with: Xwayland v: 22.1.9
    compositor: kwin_x11 driver: X: loaded: nvidia gpu: nvidia display-ID: :0
    screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 101 s-size: 483x261mm (19.02x10.28")
    s-diag: 549mm (21.61")
  Monitor-1: HDMI-0 res: 1920x1080 hz: 100 dpi: 102
    size: 480x260mm (18.9x10.24") diag: 546mm (21.49") modes: N/A
  API: OpenGL v: 4.6.0 NVIDIA 470.256.02 renderer: NVIDIA GeForce GT
    740/PCIe/SSE2 direct-render: Yes
Audio:
  Device-1: Intel NM10/ICH7 Family High Definition Audio
    vendor: Gigabyte GA-D525TUD driver: snd_hda_intel v: kernel bus-ID: 00:1b.0
    chip-ID: 8086:27d8 class-ID: 0403
  Device-2: NVIDIA GK107 HDMI Audio driver: snd_hda_intel v: kernel pcie:
    speed: 2.5 GT/s lanes: 16 bus-ID: 01:00.1 chip-ID: 10de:0e1b class-ID: 0403
  API: ALSA v: k6.1.0-30-amd64 status: kernel-api
  Server-1: PulseAudio v: 16.1 status: active
Network:
  Device-1: Qualcomm Atheros AR8131 Gigabit Ethernet
    vendor: Gigabyte GA-G31M-ES2L driver: atl1c v: kernel pcie: speed: 2.5 GT/s
    lanes: 1 port: bf00 bus-ID: 03:00.0 chip-ID: 1969:1063 class-ID: 0200
  IF: enp3s0 state: down mac: <filter>
  Device-2: Ralink RT5370 Wireless Adapter type: USB driver: rt2800usb
    bus-ID: 5-5:3 chip-ID: 148f:5370 class-ID: 0000 serial: <filter>
  IF: wlxc83a35c9505a state: down mac: <filter>
  IF-ID-1: enx72cf021cdffe state: unknown speed: -1 duplex: half
    mac: <filter>
Bluetooth:
  Device-1: Xiaomi Mi/Redmi series (RNDIS) type: USB driver: rndis_host
    v: kernel bus-ID: 5-2:7 chip-ID: 2717:ff80 class-ID: 0a00 serial: <filter>
Drives:
  Local Storage: total: 1.38 TiB used: 16.2 GiB (1.1%)
  ID-1: /dev/sda vendor: A-Data model: SU800 size: 476.94 GiB
    speed: <unknown> type: SSD serial: <filter> rev: 8B scheme: MBR
  ID-2: /dev/sdb vendor: Toshiba model: DT01ACA100 size: 931.51 GiB
    speed: <unknown> type: HDD rpm: 7200 serial: <filter> rev: A7C0 scheme: MBR
Partition:
  ID-1: / size: 173.1 GiB used: 13.79 GiB (8.0%) fs: ext4 dev: /dev/sda1
  ID-2: /home size: 14.66 GiB used: 2.41 GiB (16.4%) fs: ext4 dev: /dev/sda6
Swap:
  ID-1: swap-1 type: partition size: 8 GiB used: 0 KiB (0.0%) priority: -2
    dev: /dev/sda3
  ID-2: swap-2 type: zram size: 2.29 GiB used: 0 KiB (0.0%) priority: 100
    dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 60.0 C mobo: N/A gpu: nvidia temp: 47 C
  Fan Speeds (RPM): N/A gpu: nvidia fan: 30%
Info:
  Processes: 160 Uptime: 7m wakeups: 0 Memory: 3.82 GiB used: 1.61 GiB (42.1%)
  Init: systemd v: 252 target: graphical (5) default: graphical Compilers:
  gcc: 12.2.0 alt: 12 Packages: pm: dpkg pkgs: 1626 Shell: Bash v: 5.2.15
  running-in: konsole inxi: 3.3.26
ak@debian:~$ 
output of swapon -s

Code: Select all

ak@debian:~$ sudo swapon -s
[sudo] password for ak: 
Filename                                Type            Size            Used            Priority
/dev/sda3                               partition       8388604         0               -2
/dev/zram0                              partition       2404596         0               100
ak@debian:~$ 
Currently, I have both of them enabled.
Thanks,
GK
Last edited by GroudonandKyogre on 2025-02-05 09:37, edited 1 time in total.

CwF
Global Moderator
Global Moderator
Posts: 3252
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 69 times
Been thanked: 288 times

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#2 Post by CwF »

Mottainai

GroudonandKyogre
Posts: 55
Joined: 2024-11-27 09:35
Has thanked: 1 time
Been thanked: 1 time

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#3 Post by GroudonandKyogre »

Thanks for the posts, but I am still confused after going through the posts about which to use for specifically for me, I have 4GB of ram with 8GB swap partition on an SSD 512GB. My vm.swappiness value is set to 10.

I generally use browsers and sometimes VS Code to code in python.

I don't know if I should keep the swap partition, or reduce it, or just use zram and stop using swap completely.

As I have read from your posts, I see that zram is better for general use or so.

Thanks,
GK

GroudonandKyogre
Posts: 55
Joined: 2024-11-27 09:35
Has thanked: 1 time
Been thanked: 1 time

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#4 Post by GroudonandKyogre »

As far as my understanding goes, I think that using zram is obvious due to better performance than disk-based swap. But if I want to use swap just in case if my system needs it then should I not use zswap to manage the swap memory a little bit better? The idea is to use zram but keep zswap with a swap partition as a backup?

CwF
Global Moderator
Global Moderator
Posts: 3252
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 69 times
Been thanked: 288 times

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#5 Post by CwF »

GroudonandKyogre wrote: 2025-02-04 09:55 zswap with a swap partition
As far as over thinking goes, I'd leave your existing swap since it's already there. I would also raise swappiness or even restore to default. There are past discussions to browse on that topic also.

As I remember that system may top out at 8GB? Maybe upgrade that?
Mottainai

GroudonandKyogre
Posts: 55
Joined: 2024-11-27 09:35
Has thanked: 1 time
Been thanked: 1 time

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#6 Post by GroudonandKyogre »

CwF wrote: 2025-02-04 15:43
GroudonandKyogre wrote: 2025-02-04 09:55 zswap with a swap partition
As far as over thinking goes, I'd leave your existing swap since it's already there. I would also raise swappiness or even restore to default. There are past discussions to browse on that topic also.

As I remember that system may top out at 8GB? Maybe upgrade that?
First,I liked that "As far as overthinking goes!" :lol:
Second, As I had searched a value of 10 (or 20) is optimal for my system.
Third, No, my system is already topped up at the max, this mobo only supports DDR2 and as I know it, the limit of DDR2 is 4GB with 2 sticks.

Conclusion- So I should use both of them at the same time? Will they conflict?

Thanks,
GK

CwF
Global Moderator
Global Moderator
Posts: 3252
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 69 times
Been thanked: 288 times

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#7 Post by CwF »

GroudonandKyogre wrote: 2025-02-04 16:15 "As far as overthinking goes!" :lol:
I support one run through it all, after that it's rumination!
GroudonandKyogre wrote: 2025-02-04 16:15 As I had searched a value of 10 (or 20) is optimal for my system.
In a period correct view, your lowered swappiness is what an advanced user would do. With the advent of zram for swap, pulling more into swap while compressing will increase available memory. So my current thinking is to increase swap activity. The limiting factor for this use in older computers may be the extra hit on the processor now with compression duty, which is still faster than a disk.
GroudonandKyogre wrote: 2025-02-04 16:15 2 sticks.
Ok, the 31 would be the lower end of the series. I have a q35 with 4 slots that supports 4x2.
GroudonandKyogre wrote: 2025-02-04 16:15 Conclusion- So I should use both of them at the same time?
Yes, no conflict. They are prioritized.
Mottainai

User avatar
wizard10000
Global Moderator
Global Moderator
Posts: 1333
Joined: 2019-04-16 23:15
Location: southeastern us
Has thanked: 135 times
Been thanked: 240 times

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#8 Post by wizard10000 »

CwF wrote: 2025-02-04 17:10Yes, no conflict. They are prioritized.
No real-world experience here so I'm asking as well as sharing but wouldn't that priority require zswap to be full before moving to disk-based swap? Reason I ask is because zswap will move stale pages from zram to disk-based swap and might use less physical RAM.

edit: Overthinking myself, zram would be compressed so this might not be worth exploring as it wouldn't recover all that much RAM.
we see things not as they are, but as we are.
-- anais nin

CwF
Global Moderator
Global Moderator
Posts: 3252
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 69 times
Been thanked: 288 times

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#9 Post by CwF »

You would think, but when I ran both on a 64GB box I did see both in use without the zram maxed out. As I remember once there was something on the swap partition it is ‘stickier’, zram would clear out first. I assumed it did max the zram briefly and I didn't notice. Even now I see 129.5MB of 25.4GB zswap in use with 73GB “free”, so never go without any swap, but eventually I did eliminate partition based swap and never really considered file based swap.
wizard10000 wrote: 2025-02-04 17:42 zram would be compressed so this might not be worth exploring as it wouldn't recover all that much RAM.
...about 2:1 up to 5:1. So that 129.5 of mine could represent up to a half gig saved. wohoo!
Mottainai

GroudonandKyogre
Posts: 55
Joined: 2024-11-27 09:35
Has thanked: 1 time
Been thanked: 1 time

Re: [Software] zswap or zram? Which one to use in debian 12 with KDE Plasma

#10 Post by GroudonandKyogre »

After all of this, I came to the conclusion of using my current system configuration but with higher swappiness value of 20 and with both of them.
Thanks,
GK

Post Reply