Tune DwarFS parameters

This commit is contained in:
Kron4ek 2023-07-18 17:31:20 +05:00 committed by GitHub
parent 34a156dd0e
commit 60c44d5a16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -234,9 +234,6 @@ if [ "$(tail -c +$((offset+1)) "${script}" | head -c 6)" = "DWARFS" ]; then
dwarfs_image=1 dwarfs_image=1
fi fi
dwarfs_cache_size="128M"
dwarfs_num_workers="2"
# These arguments are used to rebuild the image when using the self-update function # These arguments are used to rebuild the image when using the self-update function
squashfs_comp_arguments=(-b 1M -comp zstd -Xcompression-level 19) squashfs_comp_arguments=(-b 1M -comp zstd -Xcompression-level 19)
dwarfs_comp_arguments=(-l7 -C zstd:level=19 --metadata-compression null \ dwarfs_comp_arguments=(-l7 -C zstd:level=19 --metadata-compression null \
@ -449,22 +446,28 @@ fi
# Set the dwarfs block cache size depending on how much RAM is available # Set the dwarfs block cache size depending on how much RAM is available
# Also set the number of workers depending on the number of CPU cores # Also set the number of workers depending on the number of CPU cores
dwarfs_cache_size="128M"
dwarfs_num_workers="2"
if [ "${dwarfs_image}" = 1 ]; then if [ "${dwarfs_image}" = 1 ]; then
if getconf _PHYS_PAGES &>/dev/null && getconf PAGE_SIZE &>/dev/null; then if getconf _PHYS_PAGES &>/dev/null && getconf PAGE_SIZE &>/dev/null; then
memory_size="$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024)))" memory_size="$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024)))"
if [ "${memory_size}" -ge 23000 ]; then if [ "${memory_size}" -ge 45000 ]; then
dwarfs_cache_size="1024M" dwarfs_cache_size="4096M"
elif [ "${memory_size}" -ge 23000 ]; then
dwarfs_cache_size="2048M"
elif [ "${memory_size}" -ge 15000 ]; then elif [ "${memory_size}" -ge 15000 ]; then
dwarfs_cache_size="512M" dwarfs_cache_size="1024M"
elif [ "${memory_size}" -ge 7000 ]; then elif [ "${memory_size}" -ge 7000 ]; then
dwarfs_cache_size="256M" dwarfs_cache_size="512M"
elif [ "${memory_size}" -ge 3000 ]; then elif [ "${memory_size}" -ge 3000 ]; then
dwarfs_cache_size="128M" dwarfs_cache_size="256M"
elif [ "${memory_size}" -ge 1500 ]; then elif [ "${memory_size}" -ge 1500 ]; then
dwarfs_cache_size="64M" dwarfs_cache_size="128M"
else else
dwarfs_cache_size="32M" dwarfs_cache_size="64M"
fi fi
fi fi
@ -840,7 +843,10 @@ if [ "${dwarfs_image}" = 1 ]; then
-o mlock=try \ -o mlock=try \
-o no_cache_image \ -o no_cache_image \
-o cache_files \ -o cache_files \
-o cachesize="${dwarfs_cache_size}") -o cachesize="${dwarfs_cache_size}" \
-o decratio=0.6 \
-o tidy_strategy=swap \
-o tidy_interval=5m)
else else
mount_command=("${mount_tool}" \ mount_command=("${mount_tool}" \
-o offset="${offset}",ro \ -o offset="${offset}",ro \