Skip to content

Commit 61cb8b9

Browse files
committed
Resolved 7 conflicted file(s) before pull
2 parents cab5080 + fa6bd06 commit 61cb8b9

7 files changed

Lines changed: 555 additions & 81 deletions

File tree

include/swap-default.conf

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Configuration for systemd-swap
22
# This file is part of systemd-swap.
33
# See swap.conf(5) for details.
4+
#
5+
# Values commented with ## are auto-detected based on hardware.
6+
# Uncomment to override with custom values.
47

58
################################################################################
69
# Swap Mode
710
#
8-
# auto - Auto-detect best mode (default)
11+
# auto - Auto-detect best mode (default, recommended)
912
# - btrfs/ext4/xfs -> zswap + swapfc
1013
# - others -> zram only
1114
# zswap+swapfc - Zswap + swap files (best for desktop/btrfs)
@@ -18,70 +21,74 @@ swap_mode=auto
1821

1922
################################################################################
2023
# Zswap Settings (used in zswap+swapfc mode)
21-
# This space is used for uncompressed memory. Since we have around a 3x compression ratio,
22-
# a system with 8 GB of RAM and 45% compressed memory usage can reach roughly 10.8 GB of
23-
# swap in RAM.
24-
#
25-
# However, keep in mind that 3.6 GB of RAM is no longer actually being used as regular RAM,
26-
# but rather as compressed cache. In practice, this is equivalent to around 15.2 GB total
27-
# (4.4 GB of RAM + 10.8 GB of swap compressed in RAM).
2824
#
29-
# 45% is a high value, but the kernel automatically manages when it is better to move swap
30-
# to storage, freeing up RAM, or when it is better to simply deallocate this memory.
31-
#
32-
# In addition, the system can automatically create swap files, allowing it to manage when
33-
# to move swap to storage. This makes it possible to use a few more gigabytes of swap when needed.
25+
# Zswap compresses pages in RAM before writing to swap disk.
26+
# With ~3x compression ratio, 8GB RAM + 50% pool = ~12GB effective swap in RAM.
27+
# The kernel auto-manages when to writeback cold pages to disk.
3428
################################################################################
3529

36-
zswap_compressor=lz4 # Compression algo: lz4 (fastest), zstd, lzo
37-
zswap_max_pool_percent=50 # Max RAM for compressed pool (50% = ~20GB swap in RAM with compression)
38-
zswap_zpool=z3fold # Allocator (z3fold uses less RAM overhead than zsmalloc)
39-
zswap_shrinker_enabled=1 # Proactively move cold pages to disk
40-
zswap_accept_threshold=85 # Restart accepting pages when pool drops to X% (more aggressive)
30+
## zswap_compressor=zstd # Compression: lz4 (fastest), zstd (balanced), lzo
31+
## zswap_max_pool_percent=50 # Max RAM % for compressed pool
32+
## zswap_zpool=zsmalloc # Allocator (zsmalloc is the only option in modern kernels)
33+
## zswap_shrinker_enabled=1 # Proactively move cold pages to disk
34+
## zswap_accept_threshold=85 # Resume accepting pages when pool drops to X%
4135

4236
################################################################################
4337
# Zram Settings (used in zram modes)
44-
# Unlike zswap, with zram the reserved space corresponds to the virtual size of the
45-
# swap being created, not to a usage limit based on a percentage of physical memory.
46-
# Therefore, 90% in zram does not represent a higher virtual swap value than 45% in zswap.
38+
#
39+
# Zram creates a compressed block device in RAM.
40+
# Unlike zswap, size is virtual (uncompressed) size, not RAM usage limit.
4741
################################################################################
4842

49-
zram_size=90% # Size of zram device (e.g., 50%, 1G)
50-
zram_alg=zstd # Compression algo
51-
zram_prio=32767 # Priority (highest)
43+
## zram_size=80% # Virtual size (e.g., 80%, 1G)
44+
## zram_alg=lz4 # Compression: lz4 (fast), zstd (better ratio)
45+
## zram_mem_limit=70% # Max physical RAM zram can use (OOM protection)
46+
## zram_prio=32767 # Priority (max = 32767)
5247

5348
# Zram Writeback (optional, off by default)
5449
# Moves incompressible/idle pages to backing storage
55-
zram_writeback=0
56-
zram_writeback_size=1G # Initial backing file size
57-
zram_writeback_max_size=8G # Max size
58-
zram_writeback_threshold=50 # Trigger when zram is X% full
50+
## zram_writeback=0
51+
## zram_writeback_size=1G # Initial backing file size
52+
## zram_writeback_max_size=8G # Max size
53+
## zram_writeback_threshold=50 # Trigger when zram is X% full
5954

6055
################################################################################
6156
# SwapFC - Dynamic Swap Files (used in swapfc modes)
57+
#
58+
# Progressive scaling: starts with base size, doubles every N files.
59+
# With 32 files max and step=3: 1G -> 1G -> 1G -> 2G -> 2G -> 2G -> 4G...
60+
# Total capacity can reach hundreds of GB while using minimal disk initially.
6261
################################################################################
6362

64-
# Progressive Scaling: Start small, grow as needed
65-
swapfc_enabled=1 # Enable swap files
66-
swapfc_path=/swapfc/swapfile # Directory and filename prefix
67-
swapfc_chunk_size=1G # Base size (larger chunks = less overhead on NVMe/SSD)
68-
swapfc_max_chunk_size=64G # Max single file size ( Theoretically be up to 16 TB or more )
69-
swapfc_max_count=16 # Max number of files (reduced to avoid fragmentation)
70-
swapfc_scaling_step=3 # Double size every X files
71-
# Doubles every 3 files e.g. 1G -> 1G -> 1G -> 2G -> 2G -> 2G -> 4G...
63+
swapfc_enabled=1
64+
swapfc_path=/swapfc/swapfile
65+
66+
# Size configuration (auto-detected based on RAM if commented)
67+
## swapfc_chunk_size=512M # Base chunk size (minimum 512M recommended)
68+
## swapfc_max_chunk_size=64G # Max single file size
69+
## swapfc_max_count=32 # Max files (kernel limit is 32)
70+
## swapfc_scaling_step=3 # Double size every X files
7271

73-
# Triggers (optimized to reduce thrashing)
74-
swapfc_free_ram_perc=20 # Create swap when free RAM < X% (rely on zswap first)
75-
swapfc_free_swap_perc=40 # Create more when free swap < X% (more proactive)
76-
swapfc_remove_free_swap_perc=70 # Remove files when free swap > X% (cleanup sooner)
72+
# Triggers (auto-tuned if commented)
73+
## swapfc_free_ram_perc=20 # Create swap when free RAM < X%
74+
## swapfc_free_swap_perc=40 # Create more when free swap < X%
75+
## swapfc_remove_free_swap_perc=70 # Remove files when free swap > X%
7776

77+
################################################################################
7878
# MGLRU Anti-Thrashing (Kernel 6.1+)
79-
# Protect working set for X ms. 0 to disable.
80-
# Higher value = better protection against thrashing, improves desktop responsiveness
81-
mglru_min_ttl_ms=5000
79+
#
80+
# Protects working set from premature eviction.
81+
# Auto-adjusted based on RAM: 1-2GB: 10s, 2-4GB: 5s, 4-8GB: 3s, 16GB+: 1s
82+
################################################################################
8283

84+
## mglru_min_ttl_ms=auto # Set to 0 to disable
85+
86+
################################################################################
8387
# Sparse Files
84-
# Pre-allocated files (sparse disabled) provide better performance under memory pressure.
85-
# Sparse files save disk space but may cause allocation delays during swap usage.
86-
# For NVMe/SSD systems with available space, pre-allocation is recommended.
87-
swapfc_use_sparse_disable=1 # Pre-allocate space for better performance
88+
#
89+
# Sparse files only use disk space when actually written to.
90+
# Enabled by default in zswap mode (disk space used only on writeback).
91+
# Pre-allocated files may have slight performance benefit but use more disk.
92+
################################################################################
93+
94+
## swapfc_use_sparse_disable=1 # Uncomment to force pre-allocation

0 commit comments

Comments
 (0)