Last active
October 14, 2024 16:12
-
-
Save phizev/31185a30e7d4984724f1fbbf9c2afe19 to your computer and use it in GitHub Desktop.
Simple, cruddy script to print out some zswap information, and attempt to calculate compression ratio, though unsure if it is accurate, nor if it accounts for overhead. Add -v to get raw dump of the module parameters and kernel debug statistics.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh - | |
ENABLED=$(cat /sys/module/zswap/parameters/enabled) | |
COMPRESSOR=$(cat /sys/module/zswap/parameters/compressor) | |
ZPOOL=$(cat /sys/module/zswap/parameters/zpool) | |
PAGE_SIZE=$(getconf PAGE_SIZE) | |
STORED_PAGES=$(cat /sys/kernel/debug/zswap/stored_pages) | |
POOL_TOTAL_SIZE=$(cat /sys/kernel/debug/zswap/pool_total_size) | |
POOL_SIZE=$(numfmt --to=iec-i $POOL_TOTAL_SIZE) | |
if [ "$POOL_TOTAL_SIZE" = "0" ] | |
then | |
DECOMPRESSED_SIZE="N/A" | |
RATIO="N/A" | |
else | |
DECOMPRESSED_SIZE=$(echo "$STORED_PAGES * $PAGE_SIZE" | bc | numfmt --to=iec-i) | |
RATIO=$(echo "scale=3; $STORED_PAGES * $PAGE_SIZE / $POOL_TOTAL_SIZE" | bc -l) | |
fi | |
echo "Zswap enabled: $ENABLED" | |
echo "Compressor: $COMPRESSOR" | |
echo "Zpool: $ZPOOL" | |
echo | |
echo "Page size: $PAGE_SIZE" | |
echo "Stored pages: $STORED_PAGES" | |
echo "Pool size: $POOL_SIZE" | |
echo "Decompressed size: $DECOMPRESSED_SIZE" | |
echo "Page compression ratio: $RATIO" | |
if [ "$1" = "-v" ] | |
then | |
echo | |
grep -R . /sys/kernel/debug/zswap/ | |
grep -R . /sys/module/zswap/parameters/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment