From d33d6b7ea2738251074146ada64f56e428ceeae5 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Thu, 18 May 2017 22:38:53 +0200
Subject: [PATCH] roles/archbuild: Merge distro swap.conf

---
 roles/archbuild/files/swap.conf | 51 +++++++++++++++++----------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/roles/archbuild/files/swap.conf b/roles/archbuild/files/swap.conf
index 45332c363..6fb7687e5 100644
--- a/roles/archbuild/files/swap.conf
+++ b/roles/archbuild/files/swap.conf
@@ -10,9 +10,9 @@
 # https://www.kernel.org/doc/Documentation/vm/zswap.txt
 
 zswap_enabled=1
-zswap_compressor=lz4
-zswap_max_pool_percent=25
-zswap_zpool=z3fold
+zswap_compressor=lz4      # lzo lz4
+zswap_max_pool_percent=25 # 1-99
+zswap_zpool=z3fold        # zbud z3fold
 
 ################################################################################
 # ZRam
@@ -22,10 +22,10 @@ zswap_zpool=z3fold
 # https://www.kernel.org/doc/Documentation/blockdev/zram.txt
 
 zram_enabled=0
-zram_size=$(($ram_size/4))K # This is 1/4 of ram size by default.
+zram_size=$(($ram_size/4))K     # This is 1/4 of ram size by default.
 zram_streams=$cpu_count
-zram_alg=lz4 # lzo lz4 deflate lz4hc 842 - for Linux 4.8.4
-zram_prio=32767
+zram_alg=lz4                    # lzo lz4 deflate lz4hc 842 - for Linux 4.8.4
+zram_prio=32767                 # 1 - 32767
 
 ################################################################################
 # Swap File Universal
@@ -44,27 +44,28 @@ swapfu_directio=0
 # files with size 2G (mounted by loop), fs: btrfs
 # fio: test 4k, randrw, iodepth 64, libaio, directio 1
 # HDD 1TB 5400k
-# loop directio 0        Behaviour                            IO/s
-# prealloc=0 + nocow=0 - NOT stable speed                   ~ 2400
-# prealloc=1 + nocow=0 - stable speed, HORRIBLY SLOW        ~  160
-# prealloc=0 + nocow=1 - stable speed, can degraded by time ~ 3300
-# prealloc=1 + nocow=1 - stable speed                       ~ 2000
-# loop directio 1
-# prealloc=0 + nocow=0 - not stable speed                   ~   50
-# prealloc=1 + nocow=0 - not stable speed                   ~   69
-# prealloc=0 + nocow=1 - not stable speed                   ~   63
-# prealloc=1 + nocow=1 - not stable speed                   ~   75
-# raw file (loop device are slow)
-# prealloc=0 + nocow=0 - not stable speed                   ~ 7600
-# prealloc=1 + nocow=0 - not stable speed                   ~   69
-# prealloc=0 + nocow=1 - not stable speed                   ~ 13000
-# prealloc=1 + nocow=1 - not stable speed                   ~  174
+# Loop device:
+# PREALLOC | NoCoW | DirectIO | ~ IO/s | Comment
+#    -     |   -   |    -     |   2400 | NOT stable speed
+#    +     |   -   |    -     |    160 | stable speed, HORRIBLY SLOW
+#    -     |   +   |    -     |   3300 | stable speed, can degraded by time
+#    +     |   +   |    -     |   2000 | stable speed
+#    -     |   -   |    +     |     50 | not stable speed
+#    +     |   -   |    +     |     69 | not stable speed
+#    -     |   +   |    +     |     63 | not stable speed
+#    +     |   +   |    +     |     75 | not stable speed
+# raw file (loop device are slow):
+# PREALLOC | NoCoW | DirectIO | ~ IO/s | Comment
+#    -     |   -   |    +     |   7600 | not stable speed
+#    +     |   -   |    +     |     69 | not stable speed
+#    -     |   +   |    +     |  13000 | not stable speed
+#    +     |   +   |    +     |    174 | not stable speed
 
 # File will not be available in fs after script start
 # Make sure what script can access to this path during the boot process.
 # Full path to swapfile
-swapfu_path=/var/swap
-swapfu_prio=-1024
+swapfu_path=/var/lib/systemd-swap/swapfu
+swapfu_prio=1     # 1 - 32767
 
 ################################################################################
 # Swap File Chunked
@@ -73,10 +74,10 @@ swapfu_prio=-1024
 swapfc_enabled=0
 swapfc_frequency=1s         # How often check free swap space
 swapfc_chunk_size=256M      # Allocate size of swap chunk
-swapfc_max_count=16         # 0 - unlimited
+swapfc_max_count=16         # 0 - unlimited, note: 32 is a kernel maximum
 swapfc_free_swap_perc=15    # Add new chunk if free < 15%
                             # Remove chunk if free > 15+40% & chunk count > 2
-swapfc_path=/var/.swapfc/
+swapfc_path=/var/lib/systemd-swap/swapfc/
 
 ################################################################################
 # Swap devices
-- 
GitLab