Which swap option do you use?

Yeah, I am aware, but if you reading here, you’ll figure out that I have no issues :slight_smile: https://forum.manjaro.org/t/clarification-about-the-behaviour-of-swappiness/43808
I’m also planning to upgrade the RAM to 32GB.

Using systemd-swap service and configuring /etc/systemd/swap.conf.d/zram.conf in this way:

zswap_enabled=0
zram_enabled=1
zram_size=$(( RAM_SIZE / 2 ))
zram_count=$(( 4 / 2 ))
zram_streams=$(( 4 / 2 ))
zram_alg=lz4
zram_prio=32767
swapfc_enabled=0
swapd_auto_swapon=0
swapd_prio=0

But, as mentioned in my other dicussion, at the moment I’m going without swap; If I’ll encounter some issue, I’ll report back :+1:

While a system can work fine this way, you might want to (re-)visit/read the “in defence of swap” article by Chris Down given earlier (see Which swap option do you use? - #28 by nam1962).

1 Like

Swap partition

Get an SSD, and/or newer devices. :slight_smile:

If you have multiple drives in your main system, you can stripe swap partitions, just create one on each drive and set the same priority for each in fstab.

Yes I am considering an inexpensive NVMe device in a PCIe X1 M.2 adaptor as a temporary upgrade until I can manage to get a new system, that should give me a fast swap device and likely /boot and root whilst I retain home on the existing hard disk.

In the meantime I have enabled zswap with systemd-swap, but it’s too recent to comment on any difference experienced.

In your case with so little RAM, using a swap that uses RAM will make your problem worse…

Sounds like a plan. :slight_smile:

I claim no expertise or special knowledge on this but whilst that comment sounds logical it is in contradiction to the zswap Linux Kernel documentation which states that amongst the potential benefits of zswap:

Desktop/laptop users with limited RAM capacities can mitigate the performance impact of swapping

Based on that it seemed a good idea to try zswap, especially as my swap device is a relatively slow spinning hard disk for which potentially reduced swap I/O may be beneficial.

Yes but a system can not create more RAM out of RAM right?
So it depends on the needs of your OS, if you have enough spare RAM to benefit from it.
In your case you mentioned:

Which looks to me like extreme limited, you can try ofcourse, but IMHO it would have same effect as not starting any extra apps besides the OS :wink:
Anyhow my advice is a faster HD, and you will only experience the difference when you use a faster HD, because “as-is” you already have a slow system so you don’t notice if it stays slow or not compared to a faster HD…

1 Like

Well, as I promised, I report my feedback about disabled swap.
Firstly I summarize my HW specs:

inxi -Fazy

Summary
System:
  Kernel: 4.14.209-1-MANJARO x86_64 bits: 64 compiler: gcc v: 10.2.0 
  parameters: BOOT_IMAGE=/boot/vmlinuz-4.14-x86_64 
  root=UUID=0d37cf27-2ff0-4234-a80e-4be323299166 rw i915.fastboot=1 
  i915.modeset=1 quiet "acpi_osi=Windows 2009" libahci.ignore_sss=1 
  random.trust_cpu=on pcie_aspm=force scsi_mod.use_blk_mq=1 nowatchdog 
  nmi_watchdog=0 mitigations=off nospec_store_bypass_disable noibrs noibpb 
  nopti nospec nospectre_v1 no_stf_barrier kvm-intel.vmentry_l1d_flush=never 
  loglevel=0 udev.log_priority=0 audit=0 net.ifnames=0 noresume 
  Desktop: Xfce 4.14.3 tk: Gtk 3.24.23 info: xfce4-panel wm: xfwm4 
  dm: LightDM 1.30.0 Distro: Manjaro Linux 
Machine:
  Type: Laptop System: Hewlett-Packard product: HP ProBook 6470b v: A1029D1102 
  serial: <filter> Chassis: type: 10 serial: <filter> 
  Mobo: Hewlett-Packard model: 179C v: KBC Version 42.38 serial: <filter> 
  BIOS: Hewlett-Packard v: 68ICE Ver. F.73 date: 08/07/2018 
Battery:
  ID-1: BAT0 charge: 60.2 Wh condition: 61.4/61.4 Wh (100%) volts: 12.2/10.8 
  model: Hewlett-Packard Primary type: Li-ion serial: <filter> status: Unknown 
  Device-1: hidpp_battery_0 model: Logitech Wireless Touch Keyboard K400 Plus 
  serial: <filter> charge: 100% (should be ignored) rechargeable: yes 
  status: Discharging 
  Device-2: hidpp_battery_1 
  model: Logitech Wireless Mobile Mouse MX Anywhere 2S serial: <filter> 
  charge: 100% (should be ignored) rechargeable: yes status: Discharging 
CPU:
  Info: Dual Core model: Intel Core i5-3210M bits: 64 type: MT MCP 
  arch: Ivy Bridge family: 6 model-id: 3A (58) stepping: 9 microcode: 20 
  L2 cache: 3072 KiB 
  flags: avx lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 19961 
  Speed: 1197 MHz min/max: 1200/3100 MHz Core speeds (MHz): 1: 1197 2: 1197 
  3: 1197 4: 1197 
  Vulnerabilities: Type: itlb_multihit status: KVM: Vulnerable 
  Type: l1tf mitigation: PTE Inversion; VMX: vulnerable 
  Type: mds status: Vulnerable; SMT vulnerable 
  Type: meltdown status: Vulnerable 
  Type: spec_store_bypass status: Vulnerable 
  Type: spectre_v1 status: Vulnerable: __user pointer sanitization and 
  usercopy barriers only; no swapgs barriers 
  Type: spectre_v2 status: Vulnerable, IBPB: disabled, STIBP: disabled 
  Type: srbds status: Vulnerable: No microcode 
  Type: tsx_async_abort status: Not affected 
Graphics:
  Device-1: Intel 3rd Gen Core processor Graphics vendor: Hewlett-Packard 
  driver: i915 v: kernel bus ID: 00:02.0 chip ID: 8086:0166 
  Display: x11 server: X.Org 1.20.10 compositor: picom v: git-dac85 
  driver: intel unloaded: modesetting alternate: fbdev,vesa display ID: :0.0 
  screens: 1 
  Screen-1: 0 s-res: 1366x768 s-dpi: 204 s-size: 170x95mm (6.7x3.7") 
  s-diag: 195mm (7.7") 
  Monitor-1: LVDS1 res: 1366x768 hz: 60 dpi: 112 size: 310x170mm (12.2x6.7") 
  diag: 354mm (13.9") 
  OpenGL: renderer: Mesa DRI Intel HD Graphics 4000 (IVB GT2) 
  v: 4.2 Mesa 20.2.3 compat-v: 3.0 direct render: Yes 
Audio:
  Device-1: Intel 7 Series/C216 Family High Definition Audio 
  vendor: Hewlett-Packard driver: snd_hda_intel v: kernel bus ID: 00:1b.0 
  chip ID: 8086:1e20 
  Sound Server: ALSA v: k4.14.209-1-MANJARO 
Network:
  Message: No Device data found. 
  Device-1: TP-Link Archer T9UH v1 [Realtek RTL8814AU] type: USB 
  driver: 8814au bus ID: 4-3:6 chip ID: 2357:0106 serial: <filter> 
  IF: wlan0 state: up mac: <filter> 
Drives:
  Local Storage: total: 698.65 GiB used: 68.57 GiB (9.8%) 
  SMART Message: Unable to run smartctl. Root privileges required. 
  ID-1: /dev/sda vendor: Samsung model: SSD 860 EVO 500GB size: 465.76 GiB 
  block size: physical: 512 B logical: 512 B speed: 6.0 Gb/s serial: <filter> 
  rev: 4B6Q scheme: MBR 
  ID-2: /dev/sdb vendor: Crucial model: CT250MX500SSD1 size: 232.89 GiB 
  block size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s serial: <filter> 
  rev: 023 scheme: MBR 
Partition:
  ID-1: / raw size: 465.76 GiB size: 457.45 GiB (98.22%) 
  used: 31.80 GiB (7.0%) fs: ext4 dev: /dev/sda1 
Swap:
  Alert: No Swap data was found. 
Sensors:
  System Temperatures: cpu: 41.0 C mobo: 0.0 C 
  Fan Speeds (RPM): N/A 
Info:
  Processes: 184 Uptime: 2d 17h 45m Memory: 15.55 GiB used: 3.67 GiB (23.6%) 
  Init: systemd v: 246 Compilers: gcc: 10.2.0 Packages: pacman: 1647 lib: 430 
  Shell: Bash v: 5.0.18 running in: xfce4-terminal inxi: 3.1.08

Tuned disk I/O scheduler (mq-deadline) for the SSD
Tuned kernel parameters in /etc/sysctl.d/99-sysctl_tweaks.conf

16GB DDR3 Ram

In these days I deliberately attempted to put under stress my system: as I stated in the other discussion I opened giantic (in the order of 6/8GB) projects in Gimp while in the meantime I had the browser (Chromium) opened with hundred of tabs, and many other applications; as well while having I/O tasks, like copy backup files of my other machines (eg. Macrium Reflect backup images) from an external disk connected on Virtual Box where there is Win 7 installed: here, from virtualized Win 7, I copyed a 15 GB file on the main SSD where Manjaro is installed and where everything resides (apart VirtualBox OSes files, which are in the second SSD).
I also executed multitasking CPU hungry processes.

Well, the system doesn’t showed any hiccups, was fluyd and smooth as ever, spectacularly rock solid.
So, I’m OK without swap.

Ok, nice.
Did you perform the same test with swap ?

Sure, because I have the habit to squeeze my computers :smiley:

In principle, when I installed Manjaro on February 2019, I setup the swap partition on the SSD: wasn’t a good choice, because during swapping the system showed some slowdowns.
Then as I mentioned, I choosed zram: was better, but during swapping, little slowdowns occurred.
The curious thing is that the swapping has always been minimal: I never seen it go above 50 MB; and also occurred when a plenty of ram was still available.

More informations:
Previously (when I had the swap) I also seen the OOM in action, sure: when triggered, used to cause a momentary flickering on the screen.
…and obviously I got the confirmation (of OOM triggered) from the journal log.
In these days, instead, no signal of OOM in action.
Anyway, I tweaked a lot the memory management using sysctl.

This is great, thanks.

They should add an option to set this up in the manjaro installer.

My knowledge was based on the quite older implementation, pre kernel 5.0 to be exact. Now btrfs wiki states they support it, with limitations, which still makes swap partition a better deal.

Some data from a classical use that show how swap is used, even when RAM is available:

[sum@ordi1 /]$ free
              total       utilisé      libre     partagé tamp/cache   disponible
Mem:          11756        6917         629        1941        4209        2221
Swap:        1279         917         362
[sum@ordi1 /]$
[sum@ordi1 /]$ swapon -s
Nom de fichier				Type		Taille	Utilisé	Priorité
/var/lib/systemd-swap/swapfc/1         	file    	262140	254156	50
/var/lib/systemd-swap/swapfc/2         	file    	262140	252672	49
/var/lib/systemd-swap/swapfc/3         	file    	262140	240560	48
/var/lib/systemd-swap/swapfc/4         	file    	262140	191684	47
/var/lib/systemd-swap/swapfc/5         	file    	262140	0	46
[sum@ordi1 /]$
systemd-swap.service - Manage swap spaces on zram, files and partitions.
     Loaded: loaded (/usr/lib/systemd/system/systemd-swap.service; enabled; vendor preset: disabled)
     Active: active (running) since Sat 2020-12-26 08:59:51 CET; 2 days ago
   Main PID: 697 (systemd-swap)
     Status: "Monitoring memory status..."
      Tasks: 1 (limit: 14083)
     Memory: 13.7M
     CGroup: /system.slice/systemd-swap.service
             └─697 /usr/bin/python3 -u /usr/bin/systemd-swap start

déc. 26 08:59:29 ordi1 systemd-swap[697]: INFO: Zswap: set new parameters: complete
déc. 26 08:59:29 ordi1 systemd-swap[697]: INFO: Writing destroy info...
déc. 26 08:59:29 ordi1 systemd-swap[697]: INFO: swapD: pick up devices from systemd-gpt-auto-generator
déc. 26 08:59:29 ordi1 systemd-swap[697]: INFO: swapD: searching swap devices
déc. 26 08:59:29 ordi1 systemd-swap[697]: INFO: swapFC: allocate chunk:  1
déc. 26 08:59:51 ordi1 systemd[1]: Started Manage swap spaces on zram, files and partitions..
déc. 27 13:54:21 ordi1 systemd-swap[697]: INFO: swapFC: free swap: 10 < 15 - allocate chunk:  2
déc. 27 17:43:03 ordi1 systemd-swap[697]: INFO: swapFC: free swap: 13 < 15 - allocate chunk:  3
déc. 27 20:35:08 ordi1 systemd-swap[697]: INFO: swapFC: free swap: 13 < 15 - allocate chunk:  4
déc. 28 09:11:18 ordi1 systemd-swap[697]: INFO: swapFC: free swap: 12 < 15 - allocate chunk:  5

What I use is encrypted swap partition.

I am a paranoic so I thinking that any party who would steal my laptop would immediately do “dd” of my drive and start looking for keys and cookies in swap.

I performed other tests:

Swap is not supposed to be a RAM extension, but a place to store unused pages.

My experience is that swap is used even if RAM is not saturated.

Almost duplicate info (from my dec 28 post):

[sum@ordi1 ~]$ free
              total       utilisé      libre     partagé tamp/cache   disponible
Mem:          11754        7950         329        2562        3474         930
Swap :        2815        2302         513
[sum@ordi1 ~]$ 
[sum@ordi1 ~]$ swapon -s
Nom de fichier				Type		Taille	Utilisé	Priorité
/var/lib/systemd-swap/swapfc/1         	file    	262140	262108	50
/var/lib/systemd-swap/swapfc/2         	file    	262140	262108	49
/var/lib/systemd-swap/swapfc/3         	file    	262140	262140	48
/var/lib/systemd-swap/swapfc/4         	file    	262140	261864	47
/var/lib/systemd-swap/swapfc/5         	file    	262140	260968	46
/var/lib/systemd-swap/swapfc/6         	file    	262140	251808	45
/var/lib/systemd-swap/swapfc/7         	file    	262140	238964	44
/var/lib/systemd-swap/swapfc/8         	file    	262140	248780	43
/var/lib/systemd-swap/swapfc/9         	file    	262140	253996	42
/var/lib/systemd-swap/swapfc/10        	file    	262140	68064	41
/var/lib/systemd-swap/swapfc/11        	file    	262140	0	40
[sum@ordi1 ~]$ 

Quite normal operation (3 firefox instances with 20/30 tabs each - shortwave - pulseeffects - gimp - wavemaker - thunderbird 20 mailboxes - filezilla - gedit - thunar)

Obviously the garbage in swapfiles would be in RAM if I had no swapfiles…

Yeah, I know: I never said the opposite.

Was the same for me; was also used with few ram usage, and I’ve done my tests to see how the system behaves without swap [*].

These should be also controlled by sysctl kernel’s settings: is about the dirty pages.
I updated my post in the other discussion with my current settings which also includes the settings for dirty pages and watermark_scale_factor (which controls the aggressiveness of kswapd).

[*] after days of RAM stressing, differently from when I had the swap, the system have a better reactiveness, is more “fluid”.

Useful: https://www.kernel.org/doc/Documentation/sysctl/vm.txt

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.