{"id":3369,"date":"2021-06-18T20:14:31","date_gmt":"2021-06-18T14:44:31","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/blog\/?p=3369"},"modified":"2023-01-23T16:32:54","modified_gmt":"2023-01-23T11:02:54","slug":"how-to-use-lightweight-compressed-cache-for-swap-pages","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/","title":{"rendered":"How to use lightweight compressed cachefor swap pages"},"content":{"rendered":"\n<p>Configure a lightweight compressed cache for swap pages to mitigate the performance impact of swapping on your desktop.<\/p>\n\n\n\n<p>This solution requires a configured swap partition as it is not intended to replace it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ swapon<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">NAME      TYPE      SIZE USED PRIO\n\/dev\/dm-2 partition  16G 4.8G   -2<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Enable zswap on a running system<\/h2>\n\n\n\n<p>Enable <code>zswap<\/code> module.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ echo Y | sudo tee \/sys\/module\/zswap\/parameters\/enabled<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Y<\/pre>\n\n\n\n<p>Use z3fold &nbsp;allocator&nbsp;as it is designed to store up to three compressed pages per physical page (default <code>zbud<\/code>).&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ echo z3fold | sudo tee \/sys\/module\/zswap\/parameters\/zpool<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">z3fold<\/pre>\n\n\n\n<p>Use fast <code>zstd<\/code> compression algorithm (default <code>lzo<\/code>).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ echo zstd | sudo tee \/sys\/module\/zswap\/parameters\/compressor<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">zstd<\/pre>\n\n\n\n<p>Define maximum memory pool in percent (default 20%)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ echo 20 | sudo tee \/sys\/module\/zswap\/parameters\/max_pool_percent<\/pre>\n\n\n\n<p>Ensure that checking for the same-value filled pages during store operation is enabled (default <code>Y<\/code>)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ echo Y | sudo tee \/sys\/module\/zswap\/parameters\/same_filled_pages_enabled<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Y<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Inspect zswap internals<\/h2>\n\n\n\n<p>Use <code>debugfs<\/code> to inspect <code>zswap<\/code> internals and determine that it is working as ex[ected.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo find \/sys\/kernel\/debug\/zswap\/ -type f -exec grep -H . {} \\;<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\/sys\/kernel\/debug\/zswap\/same_filled_pages:230585\n\/sys\/kernel\/debug\/zswap\/stored_pages:403937\n\/sys\/kernel\/debug\/zswap\/pool_total_size:287670272\n\/sys\/kernel\/debug\/zswap\/duplicate_entry:0\n\/sys\/kernel\/debug\/zswap\/written_back_pages:967347\n\/sys\/kernel\/debug\/zswap\/reject_compress_poor:0\n\/sys\/kernel\/debug\/zswap\/reject_kmemcache_fail:0\n\/sys\/kernel\/debug\/zswap\/reject_alloc_fail:0\n\/sys\/kernel\/debug\/zswap\/reject_reclaim_fail:242\n\/sys\/kernel\/debug\/zswap\/pool_limit_hit:334172<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Enable zswap at boot<\/h2>\n\n\n\n<p>Install&nbsp;<em>sysfs query tool and boot-time setup<\/em>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo apt install -y sysfsutils<\/pre>\n\n\n\n<p>Create <code>zswap<\/code> configuration.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat &lt;&lt;EOF | sudo tee \/etc\/sysfs.d\/zswap.conf\nmodule\/zswap\/parameters\/enabled = Y\nmodule\/zswap\/parameters\/zpool = z3fold\nmodule\/zswap\/parameters\/compressor = zstd\nmodule\/zswap\/parameters\/max_pool_percent = 20\nmodule\/zswap\/parameters\/same_filled_pages_enabled = Y\nEOF<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">module\/zswap\/parameters\/enabled = Y\nmodule\/zswap\/parameters\/zpool = z3fold\nmodule\/zswap\/parameters\/compressor = zstd\nmodule\/zswap\/parameters\/max_pool_percent = 20\nmodule\/zswap\/parameters\/same_filled_pages_enabled = Y<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Configure a lightweight compressed cache for swap pages to mitigate the performance impact of swapping on your desktop. This solution requires a configured swap partition as it is not intended to replace it. $ swapon NAME TYPE SIZE USED PRIO \/dev\/dm-2 partition 16G 4.8G -2 Enable zswap on a running system Enable zswap module. $ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3491,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[336,166],"tags":[],"class_list":["post-3369","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","category-ubuntu"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use lightweight compressed cachefor swap pages | 24x7serversupport Blog<\/title>\n<meta name=\"description\" content=\"How to use lightweight compressed cache for swap pages\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use lightweight compressed cachefor swap pages | 24x7serversupport Blog\" \/>\n<meta property=\"og:description\" content=\"How to use lightweight compressed cache for swap pages\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-18T14:44:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-23T11:02:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/\",\"name\":\"How to use lightweight compressed cachefor swap pages | 24x7serversupport Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg?fit=960%2C720&ssl=1\",\"datePublished\":\"2021-06-18T14:44:31+00:00\",\"dateModified\":\"2023-01-23T11:02:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"description\":\"How to use lightweight compressed cache for swap pages\",\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg?fit=960%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg?fit=960%2C720&ssl=1\",\"width\":960,\"height\":720,\"caption\":\"lightweight compressed cache\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use lightweight compressed cachefor swap pages\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use lightweight compressed cachefor swap pages | 24x7serversupport Blog","description":"How to use lightweight compressed cache for swap pages","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/","og_locale":"en_US","og_type":"article","og_title":"How to use lightweight compressed cachefor swap pages | 24x7serversupport Blog","og_description":"How to use lightweight compressed cache for swap pages","og_url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/","og_site_name":"24x7serversupport Blog","article_published_time":"2021-06-18T14:44:31+00:00","article_modified_time":"2023-01-23T11:02:54+00:00","og_image":[{"width":960,"height":720,"url":"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg","type":"image\/jpeg"}],"author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/","url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/","name":"How to use lightweight compressed cachefor swap pages | 24x7serversupport Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg?fit=960%2C720&ssl=1","datePublished":"2021-06-18T14:44:31+00:00","dateModified":"2023-01-23T11:02:54+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"description":"How to use lightweight compressed cache for swap pages","breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#primaryimage","url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg?fit=960%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg?fit=960%2C720&ssl=1","width":960,"height":720,"caption":"lightweight compressed cache"},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-use-lightweight-compressed-cache-for-swap-pages\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to use lightweight compressed cachefor swap pages"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2021\/06\/light-weight-compression-cache-.jpg?fit=960%2C720&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=3369"}],"version-history":[{"count":2,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3369\/revisions"}],"predecessor-version":[{"id":3492,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3369\/revisions\/3492"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media\/3491"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=3369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=3369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=3369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}