<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ahmad BenKhadra</title>
    <description>The latest articles on DEV Community by Ahmad BenKhadra (@abk).</description>
    <link>https://dev.to/abk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4259621%2F56d01b12-47a4-40a4-bae0-711f50a43235.png</url>
      <title>DEV Community: Ahmad BenKhadra</title>
      <link>https://dev.to/abk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abk"/>
    <language>en</language>
    <item>
      <title>We Fixed Our ZFS Write Spikes, Then Reads Got 4 Slower!</title>
      <dc:creator>Ahmad BenKhadra</dc:creator>
      <pubDate>Mon, 23 Nov 2026 03:58:44 +0000</pubDate>
      <link>https://dev.to/abk/we-fixed-our-zfs-write-spikes-then-reads-got-4x-slower-2hn0</link>
      <guid>https://dev.to/abk/we-fixed-our-zfs-write-spikes-then-reads-got-4x-slower-2hn0</guid>
      <description>&lt;p&gt;One of our databases was getting hit by long garbage-collection pauses. The trigger turned out to be ZFS: compressing writes with gzip-9 took heavy bursts of CPU, and whenever a burst collided with GC (Garbage Collection), the stop-the-world pause ran far longer than it should.&lt;/p&gt;

&lt;p&gt;We switched to zstd-1 to cut write CPU, and it worked: the long pauses vanished. Then reads on some of our environments got about 4× slower, with nothing in ZFS to explain why.&lt;/p&gt;

&lt;p&gt;The answer wasn't in ZFS. It was Safe RET, a Linux kernel security mitigation active on our AMD Genoa VMs. In the lab, turning it off just to confirm the cause (not as advice) made zstd-1 reads 4.5× faster on the exact same machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contents&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The spikes hidden inside the average&lt;/li&gt;
&lt;li&gt;A win, and an unexpected bill&lt;/li&gt;
&lt;li&gt;Chasing the slowdown into a lab&lt;/li&gt;
&lt;li&gt;Methodology&lt;/li&gt;
&lt;li&gt;No single winner&lt;/li&gt;
&lt;li&gt;Same reads, different cost&lt;/li&gt;
&lt;li&gt;
The Genoa result: a security mitigation changed the answer

&lt;ul&gt;
&lt;li&gt;Why zstd and not gzip?&lt;/li&gt;
&lt;li&gt;Turin: mitigated without Safe RET&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Choose for your workload&lt;/li&gt;
&lt;li&gt;Sources&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The spikes hidden inside the average
&lt;/h2&gt;

&lt;p&gt;It started with pauses. One of our databases regularly stopped all its work for garbage collection (a stop-the-world pause, while its runtime frees unused memory), and the long pauses hurt. Our dashboards showed nothing unusual around them, because they plotted averages.&lt;/p&gt;

&lt;p&gt;When we sampled every second instead, a pattern appeared: the pauses lined up with short bursts of ZFS compression CPU that the averages had smoothed away.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F58c3wzbo3scgcwllfyh1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F58c3wzbo3scgcwllfyh1.png" alt="Schematic with three lanes on one time axis. Compression CPU sampled every second shows tall, short bursts about 35 seconds apart. The same metric averaged, as a dashboard shows it, is a flat low line. Database stop-the-world pauses line up under each burst. Schematic, no measured values." width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Schematic: 1 s samples show compression bursts at the pauses; averages hide them.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That pointed at writes. The bursts follow from how ZFS writes. It doesn't compress a buffered write when the application calls &lt;code&gt;write()&lt;/code&gt;. It compresses when it syncs a transaction group, the batch of changes it flushes to disk. That happens "at least every" &lt;code&gt;zfs_txg_timeout&lt;/code&gt; seconds, 5 by default, or sooner when dirty data (data waiting in memory to be written) builds up (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L2397-L2399" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L1377-L1379" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;So compression CPU arrives in batches. Ours came about every 35 seconds, a cadence we observed but didn't explain.&lt;/p&gt;

&lt;p&gt;And each batch was expensive, because we were compressing with gzip-9, gzip's strongest level (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L856-L887" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;). Our lab later put a number on it: on three of our four test CPUs, gzip-9 used 4.7–8.4× the write CPU of zstd-1.&lt;/p&gt;

&lt;h2&gt;
  
  
  A win, and an unexpected bill
&lt;/h2&gt;

&lt;p&gt;zstd-1 compresses far faster, so we switched. At first it looked like a free lunch: fleet-wide ZFS compression CPU dropped by about 83% (comparing roughly 5 weeks after the change against before it), and the long pauses mostly disappeared.&lt;/p&gt;

&lt;p&gt;Then reads on some environments got about 4× slower. That was the unexpected bill.&lt;/p&gt;

&lt;p&gt;Compression isn't only paid on writes. When a read finds a compressed record in the ARC (an ARC hit), ZFS decompresses the whole record, unless an uncompressed copy is still in RAM (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L2154-L2169" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;). So a slower decoder costs CPU on every such read, with no disk involved.&lt;/p&gt;

&lt;p&gt;But a slower decoder didn't explain why only some environments slowed down, and at first we couldn't explain it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chasing the slowdown into a lab
&lt;/h2&gt;

&lt;p&gt;We started by profiling the slow production hosts. The profiles pointed toward the processors, but production hosts differ from each other in too many ways, such as hardware, load, data and configuration, to prove a cause.&lt;/p&gt;

&lt;p&gt;So we built a controlled benchmark: the same software and data on four Google Cloud virtual machine (VM) types, with the pool in RAM so that disks couldn't blur the result. If one VM type stood out, the cause would have to come with that machine type. Everything from here on is lab data, not production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Methodology
&lt;/h2&gt;

&lt;p&gt;We ran the same tests on four VM types with identical software. Each VM had 4 vCPUs (virtual CPUs). The ZFS pool sat on a RAM disk, a block device that lives in memory, so no real disk took part: the results reflect CPU and memory work, not disk speed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fth0o38c7qjc9efoxtkek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fth0o38c7qjc9efoxtkek.png" alt="Four Google Cloud VMs in us-east4-a, 4 vCPUs each: c3-standard-4 (Intel Sapphire Rapids), n4-standard-4 (Intel Emerald Rapids), c3d-standard-4 (AMD Genoa, Mitigation: Safe RET), c4d-standard-4 (AMD Turin, Mitigation: IBPB on VMEXIT only). Same Ubuntu 24.04 image, kernel 7.0.0-1014-gcp and ZFS module 2.4.1 with bundled zstd 1.4.5. Kernel states: default on all four; spec_rstack_overflow=off on c3d; mitigations=off on c3, n4 and c4d in run 1. Pool on a 4 GiB RAM disk: ashift 12, recordsize 128K, fletcher4 checksums, ARC capped at 3 GiB." width="800" height="748"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Same software and pool on all four VMs; only the machine type differs. The bold line is each kernel's SRSO status.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;GCP documents the CPU behind each series (&lt;a href="https://docs.cloud.google.com/compute/docs/general-purpose-machines" rel="noopener noreferrer"&gt;machine families&lt;/a&gt;, &lt;a href="https://docs.cloud.google.com/compute/docs/cpu-platforms" rel="noopener noreferrer"&gt;CPU platforms&lt;/a&gt;). ZFS bundles zstd 1.4.5 (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zstd/lib/zstd.h#L74-L76" rel="noopener noreferrer"&gt;&lt;code&gt;zstd.h&lt;/code&gt;&lt;/a&gt;); its gzip calls the kernel's zlib (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/gzip.c#L36-L41" rel="noopener noreferrer"&gt;&lt;code&gt;gzip.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/os/linux/spl/spl-zlib.c#L151-L187" rel="noopener noreferrer"&gt;&lt;code&gt;spl-zlib.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa02itex886a4x29c9j9m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fa02itex886a4x29c9j9m.png" alt="One test cell on a fresh dataset: W writes 512 MiB and syncs, measuring compression CPU. R-cold exports and imports the pool and reads 512 MiB, checked so that at least 90% of records miss the ARC. R-warm reads the same 512 MiB three times from the ARC, checked so that ARC data misses are at most 1% and the dbuf cache evicted at least 90% of records. R-rand does 10,000 random 4 KiB reads from the ARC (50,000 in run 1). Around every cell: a CPU calibration per kernel state, exclusion rules, medians of valid repetitions, and extra untimed cells for decompression counts and profiles." width="800" height="836"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Each operation targets one cost; the checks confirm where each read was served from.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;test cell&lt;/strong&gt; is one codec on one data set, one repetition. Each starts on a fresh dataset and runs four operations in order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;W:&lt;/strong&gt; write 512 MiB and sync. Measures compression and write CPU.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;R-cold:&lt;/strong&gt; export and import the pool (detach and reattach it; export flushes the pool's blocks from the ARC (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dsl_pool.c#L408-L413" rel="noopener noreferrer"&gt;&lt;code&gt;dsl_pool.c&lt;/code&gt;&lt;/a&gt;)), then read 512 MiB. Most records come from the RAM disk, not the ARC.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;R-warm:&lt;/strong&gt; read the same 512 MiB three times from the ARC. Measures ARC-hit decompression.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;R-rand:&lt;/strong&gt; 10,000 random 4 KiB reads from the ARC (50,000 in run 1). Measures small reads, most of which decompress a whole 128 KiB record.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A &lt;strong&gt;kernel state&lt;/strong&gt; is how the VM was booted: default, SRSO off (c3d), or &lt;code&gt;mitigations=off&lt;/code&gt; (c3, n4, c4d; run 1). &lt;code&gt;mitigations=off&lt;/code&gt; is a boot option documented as "Disable all optional CPU mitigations" (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/kernel-parameters.txt#L4080-L4091" rel="noopener noreferrer"&gt;kernel-parameters.txt&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The R-warm check matters most, because it confirms that the reads really decompressed. The dbuf cache, which holds uncompressed copies of recently used records, targets 1/32 of the ARC's target size (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L62-L65" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;), at most 96 MiB here. That is too small to hold a 512 MiB pass. So most records' uncompressed copies were evicted, and each pass decompressed them again from their compressed copies in the ARC.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Data set&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;In run&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;silesia&lt;/td&gt;
&lt;td&gt;12 mixed files: text, XML, executables, databases, images&lt;/td&gt;
&lt;td&gt;1, 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;text&lt;/td&gt;
&lt;td&gt;enwik8, the first 100 MB of an English Wikipedia dump&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;json&lt;/td&gt;
&lt;td&gt;Generated log lines, one JSON object per line; 64 MiB unique, repeated to 512 MiB&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;events&lt;/td&gt;
&lt;td&gt;Generated append-only event log: small binary-framed JSON events plus periodic snapshots; all unique&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;random&lt;/td&gt;
&lt;td&gt;Generated incompressible data, a control&lt;/td&gt;
&lt;td&gt;1, 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each data set is 16 files of 32 MiB, from deterministic generators whose output hashes were fixed before the runs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Runs.&lt;/strong&gt; We ran the benchmark twice. Numbers are run 2 unless marked.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Run 2 (main):&lt;/strong&gt; 8 codecs (off, lz4, gzip-1/6/9, zstd-1/3/9), 3 repetitions (2 for Genoa with SRSO off).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run 1:&lt;/strong&gt; adds zstd-19 and the &lt;code&gt;mitigations=off&lt;/code&gt; tests, with 5 repetitions (2 or 3 on Genoa, whose SRSO test used a separate SRSO-on boot).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Order was shuffled per repetition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CPU&lt;/strong&gt; is CPU-seconds per GiB: the CPU time spent across all vCPUs of the VM (the whole guest), divided by the GiB processed.&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;CPU&amp;nbsp;cost&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;GiB&amp;nbsp;processed&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;CPU-seconds,&amp;nbsp;summed&amp;nbsp;over&amp;nbsp;all&amp;nbsp;vCPUs&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;The CPU time comes from &lt;code&gt;/proc/schedstat&lt;/code&gt;, a file where the Linux kernel reports scheduler statistics; it sums the time tasks spent running on each CPU (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/scheduler/sched-stats.rst#L79" rel="noopener noreferrer"&gt;sched-stats.rst&lt;/a&gt;), so ZFS kernel threads count. We cross-checked it with &lt;code&gt;/proc/stat&lt;/code&gt;. Speed is MiB/s.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Counting and profiling.&lt;/strong&gt; Extra untimed cells did two jobs. In some, the Linux tracing tool bpftrace counted &lt;code&gt;zio_decompress_data&lt;/code&gt; calls, which the ARC makes to decompress a block (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L2164-L2169" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;). It counted only full 128 KiB records of the codec under test. In others, the Linux profiler &lt;code&gt;perf record&lt;/code&gt; sampled all CPUs to show which functions used the time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limits.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One VM per type: a difference includes memory, host, SMT layout (how vCPUs map to cores and threads) and clock, not only the core. Four VMs, not "AMD vs Intel".&lt;/li&gt;
&lt;li&gt;Few repetitions (3, or 2), but tight: slowest and fastest differed by under 0.8% in half of run 2's write and ARC-read cells, at most 1.3% in the headline Genoa zstd-1 cells, 19% in the noisiest.&lt;/li&gt;
&lt;li&gt;One reader thread (no parallel reads), one ZFS build, one zstd version.&lt;/li&gt;
&lt;li&gt;json and events are generated, log- and event-store-shaped, not real workloads, and not described well enough to regenerate.&lt;/li&gt;
&lt;li&gt;A RAM pool has no device I/O; real disks may differ.&lt;/li&gt;
&lt;li&gt;SRSO off always ran after SRSO on, with a reboot between; &lt;code&gt;mitigations=off&lt;/code&gt; always after the defaults.&lt;/li&gt;
&lt;li&gt;The guest reports microcode &lt;code&gt;0xffffffff&lt;/code&gt;, hiding the host's.&lt;/li&gt;
&lt;li&gt;Not recorded: the RAM-disk type (likely &lt;code&gt;brd&lt;/code&gt;, inferred from &lt;code&gt;brd&lt;/code&gt; functions in the profiles), the zlib version, and how silesia and enwik8 were extended to 512 MiB.&lt;/li&gt;
&lt;li&gt;Scripts, commands and raw data aren't published.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  No single winner
&lt;/h2&gt;

&lt;p&gt;No codec won everywhere. Which codec is best depends on the data for size, and on the CPU for speed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F34y62cirwhzmpownm0vi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F34y62cirwhzmpownm0vi.png" alt="Four panels of compression ratio by codec. events: lz4 2.11, gzip-9 3.01, zstd-1 3.20, zstd-9 3.21. json: lz4 2.35, and gzip-9, zstd-1 and zstd-9 all 4.56. silesia: lz4 2.01, gzip-9 2.97, zstd-1 2.73, zstd-9 3.06. text (run 1): lz4 1.68, gzip-9 2.56, zstd-1 2.32, zstd-9 2.66." width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;zstd-1 beats gzip-9 on events, ties on json, loses on silesia and text.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ratios were identical on every CPU. The json tie may come from rounding: ZFS stores each record in whole 4 KiB sectors, so records that compress to slightly different sizes can take the same space (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c#L1772-L1778" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;). We didn't inspect block sizes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdg95xrw3i0ruby67folx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdg95xrw3i0ruby67folx.png" alt="Two panels of CPU-seconds per GiB on silesia, lower is better. Write: gzip-9 116.3, 107.0, 77.2 on c3, n4, c4d against zstd-1 13.8, 12.8, 10.1; Genoa default gzip-9 107.5, zstd-1 50.7; Genoa with SRSO off gzip-9 104.6, zstd-1 13.5. ARC read: gzip-9 4.29, 3.98, 2.57 against zstd-1 3.71, 3.16, 2.84; Genoa default gzip-9 3.15, zstd-1 17.1; Genoa SRSO off gzip-9 3.00, zstd-1 3.99." width="800" height="892"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;zstd-1 writes cost less everywhere; its ARC reads cost far more on default Genoa.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writes.&lt;/strong&gt; zstd-1 writes were cheaper than gzip-9 everywhere, but far less so on default Genoa. Across silesia, json and events, gzip-9 used 4.7–8.4× zstd-1's write CPU on c3, n4 and c4d, but only 1.4–2.1× on default Genoa. There, zstd-1 got more expensive; gzip-9 didn't get cheaper.&lt;/p&gt;

&lt;p&gt;zstd-9 was hit too. On silesia, zstd-9 beat gzip-9's ratio (3.06× vs 2.97×) at 43–47% of gzip-9's write CPU on c3, n4 and c4d, but 115% on default Genoa.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ARC reads.&lt;/strong&gt; The table divides gzip-9's ARC-read CPU by zstd-1's. Above 1, zstd-1 is cheaper; below 1, it is more expensive. Ranges cover silesia, json and events. "SRSO off" means Safe RET disabled; the Genoa section below explains it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CPU&lt;/th&gt;
&lt;th&gt;gzip-9 ÷ zstd-1, ARC-read CPU&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;n4, Emerald Rapids&lt;/td&gt;
&lt;td&gt;1.26–1.62&lt;/td&gt;
&lt;td&gt;zstd-1 cheaper&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c3, Sapphire Rapids&lt;/td&gt;
&lt;td&gt;1.16–1.47&lt;/td&gt;
&lt;td&gt;zstd-1 cheaper&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c4d, Turin&lt;/td&gt;
&lt;td&gt;0.91–1.18&lt;/td&gt;
&lt;td&gt;about even&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c3d, Genoa, default&lt;/td&gt;
&lt;td&gt;0.18–0.24&lt;/td&gt;
&lt;td&gt;zstd-1 much more expensive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c3d, Genoa, SRSO off (diagnostic)&lt;/td&gt;
&lt;td&gt;0.75–1.05&lt;/td&gt;
&lt;td&gt;zstd-1 more expensive, except on events&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Data that doesn't compress still costs.&lt;/strong&gt; On the random set every codec reported 1.00×: ZFS stored records raw, so reads skip decompression, but writes paid for the attempt. Across both runs, gzip-9 spent 20.2–38.2 CPU-s/GiB and zstd-1 1.4–4.3. lz4 cost within 0.1 CPU-s/GiB of compression off, except one noisy cell (n4, run 2, 16% above compression off).&lt;/p&gt;

&lt;h2&gt;
  
  
  Same reads, different cost
&lt;/h2&gt;

&lt;p&gt;zstd-1 on Genoa wasn't decompressing more often. On json and events, gzip-9 and zstd-1 decompressed exactly the same number of records on every CPU, so the Genoa gap is in the cost of each decompression, not the count.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;one 512 MiB pass = 4,096 records of 128 KiB

decompressions per pass, every CPU, SRSO on or off:
              gzip-9   zstd-1
  json         4,096    4,096
  events       4,096    4,096
  silesia      4,021    3,987   (zstd-1 stored more records raw)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Random 4 KiB reads (R-rand) matched. On json and events, 96–97% decompressed a whole record for both codecs, and the rest found an uncompressed copy in RAM. On silesia, 94–95% did.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Genoa result: a security mitigation changed the answer
&lt;/h2&gt;

&lt;p&gt;The lab showed the same kind of slowdown on one VM out of four, the Genoa one. Besides the CPU model, one line in the setup diagram set it apart: its kernel reported &lt;code&gt;Mitigation: Safe RET&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On Genoa, the kernel's default mitigation for a CPU flaw called SRSO made zstd-1 slow; turning it off on the same VM made zstd-1 read about as fast as on c3 (272 vs 277 MiB/s).&lt;/p&gt;

&lt;p&gt;First, some background. The kernel is the core of the operating system; applications ask it for work through system calls. ZFS runs inside the kernel as a module, so every compression and decompression is kernel code. That matters, because Safe RET changes how kernel code runs.&lt;/p&gt;

&lt;p&gt;Four steps explain it: what a return is, how the CPU predicts it, what SRSO attacks, and what Safe RET does about it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. A return jumps back to the caller.&lt;/strong&gt; Programs are built from functions that call each other. When a function finishes, it runs a return instruction (&lt;code&gt;ret&lt;/code&gt; on x86) that jumps back to the code that called it. The kernel, including ZFS and its codecs, does this constantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The CPU guesses where each return goes.&lt;/strong&gt; CPUs run ahead before they know for sure where the program goes next. This is speculative execution, used "to improve performance" (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/spectre.rst#L53-L58" rel="noopener noreferrer"&gt;spectre.rst&lt;/a&gt;). For returns, "AMD CPUs predict RET instructions using a Return Address Predictor" (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L13-L14" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;). A wrong guess is a misprediction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. SRSO lets an attacker steer that guess.&lt;/strong&gt; SRSO (Inception, CVE-2023-20569) lets an attacker mis-train an AMD CPU to "control the speculative target of a subsequent kernel RET, potentially leading to information disclosure" (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L13-L25" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;). Put simply, when a kernel function returns, the CPU can be tricked into speculatively running attacker-chosen code, which can leak data (&lt;a href="https://www.amd.com/en/resources/product-security/bulletin/amd-sb-7005.html" rel="noopener noreferrer"&gt;AMD-SB-7005&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Safe RET makes every return mispredict, on purpose.&lt;/strong&gt; Safe RET is the kernel's default defence on affected CPUs, Zen 1 to Zen 4 (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L30-L31" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L85-L91" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;). It "forces the CPU to mispredict every function return using a 'safe return' sequence" (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L158-L162" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;). The guess always goes to a location the kernel controls, which is meant to keep an attacker from steering it. That closes the hole, but every kernel return now pays for a misprediction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcp5hkaz9ky8hsl83uofz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcp5hkaz9ky8hsl83uofz.png" alt="Two lanes. Normal return: the caller calls a function, the function ends with ret, and the CPU's guess of where to return is right, so the caller continues. With Safe RET, the default on Zen 1 to 4: the function's return is compiled as a jump to the return thunk, which runs the safe-return sequence; the CPU's guess goes to a controlled location, a forced misprediction, and then the real return reaches the caller. Footer: cost should grow with kernel returns more than with bytes, and an untraining sequence also runs on each kernel entry." width="800" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Safe RET sends every kernel return's guess to a controlled location, so each return mispredicts on purpose.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the kernel applies it.&lt;/strong&gt; In kernels built with return-thunk support, as distro kernels are, every kernel function return is compiled as a jump to a return thunk, one shared piece of code that performs the return (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/Makefile#L25-L28" rel="noopener noreferrer"&gt;&lt;code&gt;Makefile&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/Makefile#L215" rel="noopener noreferrer"&gt;L215&lt;/a&gt;). At boot and when a module such as ZFS loads, the kernel rewrites those jumps to the Safe RET sequence, or to a plain &lt;code&gt;ret&lt;/code&gt; when no return mitigation is needed (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/alternative.c#L1043-L1110" rel="noopener noreferrer"&gt;&lt;code&gt;alternative.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/alternative.c#L2424" rel="noopener noreferrer"&gt;boot&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/module.c#L296-L299" rel="noopener noreferrer"&gt;&lt;code&gt;module.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So the cost should follow returns more than bytes.&lt;/strong&gt; Most of Safe RET's cost should grow with the number of kernel function returns more than with bytes processed. The docs say only that it "does come at the cost of some performance depending on the workload" (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L145-L146" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The test.&lt;/strong&gt; Our c3d VM reported &lt;code&gt;Mitigation: Safe RET&lt;/code&gt;. We rebooted it with only &lt;code&gt;spec_rstack_overflow=off&lt;/code&gt; (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/kernel-parameters.txt#L7194-L7205" rel="noopener noreferrer"&gt;kernel-parameters.txt&lt;/a&gt;), changing only its SRSO status, and reran the same test cells. We call this state "SRSO off": Safe RET disabled.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A diagnostic experiment, not advice.&lt;/strong&gt; We turned SRSO off only to find the cause: the kernel docs frame it as an option for those who trust their userspace (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L145-L148" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;), and AMD "recommends users evaluate their risk environment" (&lt;a href="https://www.amd.com/en/resources/product-security/bulletin/amd-sb-7005.html" rel="noopener noreferrer"&gt;AMD-SB-7005&lt;/a&gt;).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5deqrqqlf6znc6m9zorq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5deqrqqlf6znc6m9zorq.png" alt="Bar chart of speed-up with SRSO off divided by default, on the same c3d VM, run 2, with bars starting at 1× (no change). ARC read: zstd-1 4.52, 4.37, 4.38 on silesia, json, events, with silesia going from 60 to 272 MiB/s; gzip-9 1.04, 1.01, 1.00; compression off 1.19, 1.27, 1.25. Write: zstd-1 3.66, 3.64, 3.67; gzip-9 1.03, 1.04, 1.05; compression off 1.26, 1.33, 1.29." width="800" height="824"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With SRSO off (Safe RET disabled), zstd-1 ran 3.6–4.5× faster on Genoa; gzip-9 barely moved.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In run 2, zstd-1 ARC reads ran 4.37–4.52× faster and writes 3.64–3.67×; gzip-9 changed by 0–5%.&lt;/p&gt;

&lt;p&gt;Compression off, with no codec work, still gained 19–33%. Safe RET has a second cost that probably explains this. Each time code enters the kernel, for example with a system call, Safe RET runs an untraining sequence that evicts "a potentially poisoned" entry from the branch predictor, the part of the CPU that guesses where branches and returns go (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/cpu/bugs.c#L3004-L3019" rel="noopener noreferrer"&gt;&lt;code&gt;bugs.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L164-L169" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/include/asm/nospec-branch.h#L259-L263" rel="noopener noreferrer"&gt;&lt;code&gt;nospec-branch.h&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/entry/entry_64.S#L118" rel="noopener noreferrer"&gt;&lt;code&gt;entry_64.S&lt;/code&gt;&lt;/a&gt;). That is a cost per system call, not per byte.&lt;/p&gt;

&lt;p&gt;Run 1 (silesia, 2 repetitions per state) agreed for zstd-1 reads (4.47×), and showed lz4's ARC reads 3.25× faster with SRSO off, so lz4 is exposed too.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why zstd and not gzip?
&lt;/h3&gt;

&lt;p&gt;The profiles fit a cost paid per function return, but don't prove it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;gzip-9: one long loop.&lt;/strong&gt; On Genoa's ARC reads, gzip-9 spent 69–81% of busy CPU in one function, &lt;code&gt;inflate_fast&lt;/code&gt; (the low end includes unrelated samples). The kernel's zlib says it takes "more than 95% of the inflate execution time" with large buffers (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/lib/zlib_inflate/inffast.c#L30-L36" rel="noopener noreferrer"&gt;&lt;code&gt;inffast.c&lt;/code&gt;&lt;/a&gt;). One long loop means few returns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;zstd-1: many small functions.&lt;/strong&gt; zstd-1's time was spread out. &lt;code&gt;ZSTD_decompressSequences&lt;/code&gt; (the &lt;code&gt;_bmi2&lt;/code&gt; variant) took 20–25%. Small helpers such as &lt;code&gt;BIT_readBits&lt;/code&gt;, &lt;code&gt;BIT_lookBits&lt;/code&gt; and &lt;code&gt;BIT_skipBits&lt;/code&gt; appeared in the profile as separate functions (symbols), at 4–11% each. That suggests some hot helpers aren't inlined in this build. Inlining means the compiler copies a small function's code into its caller, so there is no call and no return. Without it, each call ends in a return. We didn't disassemble the module to confirm it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More returns, more forced mispredictions.&lt;/strong&gt; More returns per byte would mean more forced mispredictions. A kernel commit saw the same effect: inlining one function in a BPF lookup cut its latency 7–8% on AMD, which the author attributed to SRSO (&lt;a href="https://github.com/torvalds/linux/commit/1a4a0cb7985f921548f1a7ac17686afbefe67f87" rel="noopener noreferrer"&gt;commit 1a4a0cb7985f&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What we didn't check.&lt;/strong&gt; The thunk itself takes under 1% of samples, likely because a misprediction's cost lands on the code it returns to. Counting returns and mispredicted returns with &lt;code&gt;perf stat&lt;/code&gt; (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L175-L207" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;) would test this; we didn't, nor did we build zstd with more inlining.&lt;/p&gt;

&lt;h3&gt;
  
  
  Turin: mitigated without Safe RET
&lt;/h3&gt;

&lt;p&gt;The kernel treats Turin as affected too, but picked a mitigation that adds nothing to our VM's own code paths. c4d (Turin; Zen 5 per &lt;a href="https://www.amd.com/en/newsroom/press-releases/2024-10-10-amd-launches-5th-gen-amd-epyc-cpus-maintaining-le.html" rel="noopener noreferrer"&gt;AMD&lt;/a&gt;) reported &lt;code&gt;Mitigation: IBPB on VMEXIT only&lt;/code&gt;, and ran the fastest zstd-1 reads in our test, 363 MiB/s on silesia.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The kernel marks Zen 5 as affected.&lt;/strong&gt; The v7.0 code (not yet the docs) marks Zen 5 as affected by SRSO (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/cpu/common.c#L1342-L1345" rel="noopener noreferrer"&gt;&lt;code&gt;common.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The CPU can say the user/kernel boundary is safe.&lt;/strong&gt; If the CPU reports &lt;code&gt;SRSO_USER_KERNEL_NO&lt;/code&gt; (not vulnerable across the user/kernel boundary), the kernel skips Safe RET. Instead it flushes the branch predictor on VM exit, when a guest (the VM) hands control back to its host (the hypervisor on the physical machine). The flush is IBPB, an "indirect branch prediction barrier" (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L150-L151" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;). If the CPU also reports BpSpecReduce, the kernel uses "Reduced Speculation" instead (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/cpu/bugs.c#L2944-L2963" rel="noopener noreferrer"&gt;&lt;code&gt;bugs.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/commit/877818802c3e970f67ccb53012facc78bef5f97a" rel="noopener noreferrer"&gt;commit 877818802c3e&lt;/a&gt;); ours didn't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. That mode protects the host, not the guest.&lt;/strong&gt; The docs say the IBPB mode covers "the Guest-&amp;gt;Host transitions only" (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst#L100-L105" rel="noopener noreferrer"&gt;srso.rst&lt;/a&gt;): it protects a host from its VMs. Our c4d kernel is itself a guest and runs no VMs, so the mode adds nothing to its own code paths (&lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/cpu/bugs.c#L3031-L3038" rel="noopener noreferrer"&gt;&lt;code&gt;bugs.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9xy7ypqlmuhehyv4la81.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9xy7ypqlmuhehyv4la81.png" alt="Decision flow, Linux v7.0 default path, simplified. Is the CPU affected by SRSO? No: not affected (c3, n4, per their reported status). Yes: does the CPU report SRSO_USER_KERNEL_NO? No: Safe RET, every kernel return mispredicts and untraining runs on kernel entry (c3d, Genoa). Yes: does it also report BpSpecReduce? Yes: Reduced Speculation. No: IBPB on VM exit, which protects the host from its VMs and adds nothing to a guest that runs no VMs (c4d, Turin, our inference)." width="800" height="628"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Turin skips Safe RET because its CPU reports the user/kernel boundary as safe; Genoa's doesn't.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That the guest saw &lt;code&gt;SRSO_USER_KERNEL_NO&lt;/code&gt; is our inference from its status string; other kernels or hypervisors may choose differently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The other three VMs: all mitigations off barely moved codec throughput.&lt;/strong&gt; On c3, n4 and c4d, &lt;code&gt;mitigations=off&lt;/code&gt; (run 1, silesia) moved ARC-read and write throughput for every codec by −0.7% to +1.8%, and with compression off by −7.3% to +6.9%.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose for your workload
&lt;/h2&gt;

&lt;p&gt;Test the codec on the hardware and kernel you run, with the reads and writes you actually have. This grid sums up why: the same codec can be cheap on one CPU and expensive on another.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F98n81rswegagk8wsbih9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F98n81rswegagk8wsbih9.png" alt="Heat grid of median CPU-seconds per GiB on silesia, run 2, coloured on a log scale per panel. Colour key: light cells use less CPU (better), dark cells use more CPU (worse). Columns: c3 Sapphire Rapids, n4 Emerald Rapids, c4d Turin, c3d Genoa default (Safe RET on, outlined), and c3d Genoa with SRSO off (diagnostic). Write: off 1.43, 1.77, 0.69, 1.30, 1.01; lz4 3.82, 3.80, 2.25, 3.66, not run; zstd-1 13.80, 12.83, 10.15, 50.72, 13.51; gzip-9 116.31, 107.03, 77.23, 107.50, 104.57; zstd-9 49.89, 46.86, 36.16, 123.65, not run. ARC read: off 0.21, 0.27, 0.08, 0.16, 0.13; lz4 0.67, 0.72, 0.47, 2.16, not run; zstd-1 3.71, 3.16, 2.84, 17.08, 3.99; gzip-9 4.29, 3.98, 2.57, 3.15, 3.00; zstd-9 3.81, 3.34, 3.08, 18.83, not run. Ratios: off 1.00, lz4 2.01, zstd-1 2.73, gzip-9 2.97, zstd-9 3.06. Footer: zstd-1 writes are cheap everywhere, but on Genoa's default kernel its ARC reads cost 5 times gzip-9's, and lz4 reads cost 3 to 5 times more than on the other CPUs." width="800" height="820"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Darker cells cost more CPU, so lighter is better; a higher ratio means smaller on disk. Read across a row: one column breaks the pattern, Genoa with Safe RET on.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decision aid&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;What matters most:&lt;/strong&gt; capacity, write latency, read latency or CPU headroom?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Which reads dominate:&lt;/strong&gt; disk, ARC, or uncompressed copies in RAM (usually the dbuf cache)?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What are your real request sizes and data?&lt;/strong&gt; Small reads from big records decompress whole records, unless cached uncompressed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure lz4, zstd-1 and your current codec&lt;/strong&gt; on production-like hosts and kernel settings; record each host type's &lt;code&gt;spec_rstack_overflow&lt;/code&gt; status (&lt;code&gt;cat /sys/devices/system/cpu/vulnerabilities/spec_rstack_overflow&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If capacity matters,&lt;/strong&gt; test whether a higher level pays for itself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch 1 s peaks, tail latency and application pauses,&lt;/strong&gt; not averages.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Rolling it out.&lt;/strong&gt; Canary on a few hosts of each type first. A new &lt;code&gt;compression&lt;/code&gt; value "affects only newly-written data" (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L916-L918" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;), so read costs shift only as records are rewritten.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Linux sources are pinned to tag &lt;code&gt;v7.0&lt;/code&gt;; the test kernel was Ubuntu's &lt;code&gt;7.0.0-1014-gcp&lt;/code&gt;, whose patches we did not diff. OpenZFS is pinned to upstream &lt;a href="https://github.com/openzfs/zfs/releases/tag/zfs-2.4.1" rel="noopener noreferrer"&gt;&lt;code&gt;zfs-2.4.1&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux kernel docs: &lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/srso.rst" rel="noopener noreferrer"&gt;SRSO (srso.rst)&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/hw-vuln/spectre.rst" rel="noopener noreferrer"&gt;Spectre (spectre.rst)&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/scheduler/sched-stats.rst" rel="noopener noreferrer"&gt;sched-stats.rst&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/Documentation/admin-guide/kernel-parameters.txt" rel="noopener noreferrer"&gt;kernel-parameters.txt&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Linux kernel source: &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/cpu/bugs.c" rel="noopener noreferrer"&gt;&lt;code&gt;arch/x86/kernel/cpu/bugs.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/cpu/common.c#L1342-L1345" rel="noopener noreferrer"&gt;&lt;code&gt;arch/x86/kernel/cpu/common.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/Makefile" rel="noopener noreferrer"&gt;&lt;code&gt;arch/x86/Makefile&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/alternative.c" rel="noopener noreferrer"&gt;&lt;code&gt;arch/x86/kernel/alternative.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/kernel/module.c" rel="noopener noreferrer"&gt;&lt;code&gt;arch/x86/kernel/module.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/include/asm/nospec-branch.h" rel="noopener noreferrer"&gt;&lt;code&gt;arch/x86/include/asm/nospec-branch.h&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/arch/x86/entry/entry_64.S" rel="noopener noreferrer"&gt;&lt;code&gt;arch/x86/entry/entry_64.S&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/blob/v7.0/lib/zlib_inflate/inffast.c#L30-L36" rel="noopener noreferrer"&gt;&lt;code&gt;lib/zlib_inflate/inffast.c&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Linux commits: &lt;a href="https://github.com/torvalds/linux/commit/877818802c3e970f67ccb53012facc78bef5f97a" rel="noopener noreferrer"&gt;877818802c3e, "x86/bugs: Add SRSO_USER_KERNEL_NO support"&lt;/a&gt;, &lt;a href="https://github.com/torvalds/linux/commit/1a4a0cb7985f921548f1a7ac17686afbefe67f87" rel="noopener noreferrer"&gt;1a4a0cb7985f, "bpf/lpm_trie: Inline longest_prefix_match for fastpath"&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;AMD, &lt;a href="https://www.amd.com/en/resources/product-security/bulletin/amd-sb-7005.html" rel="noopener noreferrer"&gt;AMD-SB-7005: Return Address Security Bulletin&lt;/a&gt;, &lt;a href="https://www.amd.com/en/newsroom/press-releases/2024-10-10-amd-launches-5th-gen-amd-epyc-cpus-maintaining-le.html" rel="noopener noreferrer"&gt;5th Gen EPYC (Turin, Zen 5) launch&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud: &lt;a href="https://docs.cloud.google.com/compute/docs/general-purpose-machines" rel="noopener noreferrer"&gt;General-purpose machine family&lt;/a&gt;, &lt;a href="https://docs.cloud.google.com/compute/docs/cpu-platforms" rel="noopener noreferrer"&gt;CPU platforms&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenZFS: &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/gzip.c" rel="noopener noreferrer"&gt;&lt;code&gt;gzip.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/os/linux/spl/spl-zlib.c" rel="noopener noreferrer"&gt;&lt;code&gt;spl-zlib.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dsl_pool.c" rel="noopener noreferrer"&gt;&lt;code&gt;dsl_pool.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zstd/lib/zstd.h#L74-L76" rel="noopener noreferrer"&gt;&lt;code&gt;module/zstd/lib/zstd.h&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>zfs</category>
      <category>security</category>
      <category>amd</category>
      <category>performance</category>
    </item>
    <item>
      <title>Cutting Cloud Disk Bills by Two-Thirds with ZFS Compression, and What It Costs in CPU</title>
      <dc:creator>Ahmad BenKhadra</dc:creator>
      <pubDate>Mon, 23 Nov 2026 03:51:33 +0000</pubDate>
      <link>https://dev.to/abk/cutting-cloud-disk-bills-by-two-thirds-with-zfs-compression-and-what-it-costs-in-cpu-3d71</link>
      <guid>https://dev.to/abk/cutting-cloud-disk-bills-by-two-thirds-with-zfs-compression-and-what-it-costs-in-cpu-3d71</guid>
      <description>&lt;p&gt;Cloud disks, such as Google Cloud's, are billed by the size you provision, so storing fewer bytes should cost less. ZFS, a file system that runs on Linux through OpenZFS, can compress data as it writes it. This article explains when that saves money, what it costs in CPU, and how ZFS decides what to compress.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contents&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Disks are billed by size, and they only grow&lt;/li&gt;
&lt;li&gt;Putting numbers on the saving&lt;/li&gt;
&lt;li&gt;How ZFS organizes data&lt;/li&gt;
&lt;li&gt;Follow a write&lt;/li&gt;
&lt;li&gt;Two rules decide the real saving&lt;/li&gt;
&lt;li&gt;Follow a read&lt;/li&gt;
&lt;li&gt;Before choosing a codec&lt;/li&gt;
&lt;li&gt;Sources&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Disks are billed by size, and they only grow
&lt;/h2&gt;

&lt;p&gt;On Google Cloud, you pay for the disk size you ask for, not for the data you put on it so if you provision a 200 GB disk, you are billed for that entire disk space, regardless of how you use it (&lt;a href="https://cloud.google.com/compute/disks-image-pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt;). And a disk can only grow. You can't reduce the size of a disk; to shrink one, you replace it with a smaller one (&lt;a href="https://docs.cloud.google.com/compute/docs/disks/resize-persistent-disk" rel="noopener noreferrer"&gt;resize docs&lt;/a&gt;). Hyperdisk volumes work the same way: You can't reduce the size of a Hyperdisk volume (&lt;a href="https://docs.cloud.google.com/compute/docs/disks/modify-hyperdisks" rel="noopener noreferrer"&gt;Hyperdisk docs&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;So compression saves money in two ways. A disk you already have fills more slowly, so you resize it later. And when you set up a new system or migrate an old one, you can provision a smaller disk from the start.&lt;/p&gt;

&lt;p&gt;The price is CPU time. ZFS spends it compressing data when it writes (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c#L1972-L1984" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;) and decompressing data when it reads, even when that data is already in RAM (there is an exception coming below) (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L2154-L2169" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Here is what the disk space costs. These are on-demand list prices for zonal disks (disks that live in a single zone) in us-east4, as of 2026-11-16 (&lt;a href="https://cloud.google.com/compute/disks-image-pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt;). &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Disk type (zonal, us-east4)&lt;/th&gt;
&lt;th&gt;Price per GiB-month&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;pd-balanced&lt;/td&gt;
&lt;td&gt;$0.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pd-ssd&lt;/td&gt;
&lt;td&gt;$0.187&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hyperdisk Balanced&lt;/td&gt;
&lt;td&gt;$0.08, plus IOPS and throughput above the included baseline&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Regional disks cost twice as much (&lt;a href="https://cloud.google.com/compute/disks-image-pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt;). Committed-use discounts, which lower prices in return for a one- or three-year commitment, aren't available for these disks (&lt;a href="https://docs.cloud.google.com/compute/docs/instances/committed-use-discounts-overview" rel="noopener noreferrer"&gt;CUD overview&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting numbers on the saving
&lt;/h2&gt;

&lt;p&gt;Compression pays off most on data that is written once and rarely read again. An event store is a good example: new rows are appended at the end, old rows are seldom read, so most of the compression CPU is paid once, when the data is written.&lt;/p&gt;

&lt;p&gt;Our generated, append-only events data set compressed 3.20× with zstd-1 and 3.01× with gzip-9, as ZFS reports it in its &lt;code&gt;compressratio&lt;/code&gt; statistic. Our numbers come from a benchmark we ran on Google Cloud VMs with OpenZFS 2.4.1: 512 MiB per data set, stored in 128 KiB records. zstd and gzip are compression algorithms, or codecs, and the number is the level: 1 is fastest, and the top level (9 for gzip, 19 for zstd) gives the best compression ratio (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L856-L887" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;A ratio of N× means 1/N of the bytes are left, so the saving is:&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;saving&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathnormal"&gt;N&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;at&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;3.20&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;×&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;3.2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;0.6875&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;68.75%&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;So at 3.20× you save 68.75%, not 220%.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ratio&lt;/th&gt;
&lt;th&gt;Bytes left&lt;/th&gt;
&lt;th&gt;Saving&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2×&lt;/td&gt;
&lt;td&gt;50%&lt;/td&gt;
&lt;td&gt;50%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3×&lt;/td&gt;
&lt;td&gt;33.3%&lt;/td&gt;
&lt;td&gt;66.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.20×&lt;/td&gt;
&lt;td&gt;31.25%&lt;/td&gt;
&lt;td&gt;68.75%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4×&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;td&gt;75%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each step up is worth less than the last: going from 3× to 4× saves only another 8.3 percentage points.&lt;/p&gt;

&lt;p&gt;Now put numbers on it. Take 10 TiB (10,240 GiB) of history. The disk has to be bigger than the data, for two reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Room to grow.&lt;/strong&gt; We assume you keep 20% free.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slop space.&lt;/strong&gt; A ZFS pool (the storage ZFS builds from your disks) can't be filled to the last byte. ZFS holds back "the last 3.2% (1/2^spa_slop_shift)" of the pool (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L573-L582" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;). In the code it is about 
&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;min&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size2"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;32&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord text mtight"&gt;&lt;span class="mord mtight"&gt;pool&amp;nbsp;size&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;span class="mspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;128&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;GiB&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size2"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
, counting a small area set aside for the intent log, where ZFS records sync writes (more on those below) (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/spa_misc.c#L1973-L1992" rel="noopener noreferrer"&gt;&lt;code&gt;spa_misc.c&lt;/code&gt;&lt;/a&gt;). Both disks in this example are 4 TiB or more, so both hit the 128 GiB cap. Smaller pools use 3.2%.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That makes the disk roughly:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;disk&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≈&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;0.8&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;data&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;+&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;128&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;GiB&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;With our numbers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 uncompressed    zstd-1, 3.20×
data             10,240 GiB      3,200 GiB
÷ 0.8            12,800 GiB      4,000 GiB      (20% free)
+ slop              128 GiB        128 GiB
disk             12,928 GiB      4,128 GiB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj65ywzpe3vwh6xpw84f3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj65ywzpe3vwh6xpw84f3.png" alt="Bar chart: 10,240 GiB of data needs a 12,928 GiB disk uncompressed and a 4,128 GiB disk at 3.20×. Monthly cost in us-east4 drops from $1,422 to $454 on pd-balanced, $2,418 to $772 on pd-ssd, and $1,034 to $330 on Hyperdisk Balanced (capacity only)." width="800" height="580"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;At 3.20×, the disk and the monthly bill both shrink to about a third.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Over a year, that saves $11,616 on pd-balanced and $19,747 on pd-ssd.&lt;/p&gt;

&lt;p&gt;On a disk you already have, compression delays the next resize: at a steady growth rate, a disk that would fill in one year uncompressed lasts 3.2 years.&lt;/p&gt;

&lt;p&gt;There is one catch: a smaller disk can also be a slower one. Google warns: "Since disk performance grows linearly with the size of your disk, consider your I/O needs when choosing the size of your disk" (&lt;a href="https://cloud.google.com/compute/disks-image-pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt;). So a smaller Persistent Disk can have lower limits on IOPS (read and write operations per second) and throughput.&lt;/p&gt;

&lt;p&gt;Hyperdisk Balanced works differently. It includes 3,000 IOPS and 140 MBps and bills performance above that separately (&lt;a href="https://cloud.google.com/compute/disks-image-pricing" rel="noopener noreferrer"&gt;pricing&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Before counting on any of these numbers, check whether your database already compresses its own data, because compressing it twice gains little. Elasticsearch compresses stored data with LZ4 by default, or with zstd under &lt;code&gt;index.codec: best_compression&lt;/code&gt; (&lt;a href="https://www.elastic.co/docs/reference/elasticsearch/index-settings/index-modules" rel="noopener noreferrer"&gt;Elastic docs&lt;/a&gt;). PostgreSQL compresses values through TOAST only when a row is wider than about 2 kB (&lt;a href="https://www.postgresql.org/docs/18/storage-toast.html" rel="noopener noreferrer"&gt;PostgreSQL docs&lt;/a&gt;).&lt;/p&gt;
&lt;h2&gt;
  
  
  How ZFS organizes data
&lt;/h2&gt;

&lt;p&gt;To see where the CPU goes, it helps to know how ZFS lays data out.&lt;/p&gt;

&lt;p&gt;On Linux, a file system is the layer that turns a raw disk into files and directories. Many file systems, such as ext4, sit on one block device: a disk, a partition, or a volume that another tool, such as LVM, builds from several disks. ZFS manages the disks itself: you give it disks, it combines them into a pool, and you create file systems, called datasets, inside that pool.&lt;/p&gt;

&lt;p&gt;ZFS doesn't compress whole files. It splits each file into records and compresses each record on its own.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fngd4g6qobcsfas9tc2ws.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fngd4g6qobcsfas9tc2ws.png" alt="Diagram: a pool of disks holds datasets; each dataset has properties such as compression and recordsize; a dataset holds files; a file is stored as records of up to 128 KiB; each record is compressed on its own and stored in 4 KiB sectors." width="800" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Each record is compressed alone and stored in whole sectors.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;From the top down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pool:&lt;/strong&gt; "a collection of devices that provides physical storage" for datasets (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man8/zpool.8#L51-L53" rel="noopener noreferrer"&gt;zpool(8)&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dataset:&lt;/strong&gt; a file system or volume in the pool (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man8/zfs.8#L89-L101" rel="noopener noreferrer"&gt;zfs(8)&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Property:&lt;/strong&gt; a named setting on a dataset, such as &lt;code&gt;compression&lt;/code&gt; (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L51-L66" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Record:&lt;/strong&gt; a file's unit of storage, which ZFS also calls a block. &lt;code&gt;recordsize&lt;/code&gt;, 128 KiB by default, is the largest record size (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zcommon/zfs_prop.c#L735-L736" rel="noopener noreferrer"&gt;&lt;code&gt;zfs_prop.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/include/sys/fs/zfs.h#L1958-L1961" rel="noopener noreferrer"&gt;&lt;code&gt;zfs.h&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sector:&lt;/strong&gt; the smallest unit ZFS writes to a disk, 2^&lt;code&gt;ashift&lt;/code&gt; bytes. &lt;code&gt;ashift=12&lt;/code&gt; means 4 KiB (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zpoolprops.7#L222-L233" rel="noopener noreferrer"&gt;zpoolprops(7)&lt;/a&gt;). &lt;code&gt;ashift&lt;/code&gt; is set per vdev (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/vdev.c#L1518-L1532" rel="noopener noreferrer"&gt;&lt;code&gt;vdev.c&lt;/code&gt;&lt;/a&gt;). A vdev is one of the disks or disk groups (a mirror, or a RAID-Z group) that a pool is built from (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zpoolconcepts.7#L39-L42" rel="noopener noreferrer"&gt;zpoolconcepts(7)&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compression is controlled by the &lt;code&gt;compression&lt;/code&gt; property. If you set nothing, it is &lt;code&gt;on&lt;/code&gt;, which means the lz4 codec when the pool's &lt;code&gt;lz4_compress&lt;/code&gt; feature is enabled, as it is on current pools (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L810-L826" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio_compress.c#L107-L112" rel="noopener noreferrer"&gt;&lt;code&gt;zio_compress.c&lt;/code&gt;&lt;/a&gt;). If you change it later, the change "affects only newly-written data" (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L916-L918" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;).&lt;/p&gt;
&lt;h2&gt;
  
  
  Follow a write
&lt;/h2&gt;

&lt;p&gt;When an application saves data, it calls &lt;code&gt;write()&lt;/code&gt;, a system call: a request to the Linux kernel, the core of the operating system, in this case to write bytes to a file. A successful &lt;code&gt;write()&lt;/code&gt; doesn't promise the data is on disk yet (&lt;a href="https://man7.org/linux/man-pages/man2/write.2.html" rel="noopener noreferrer"&gt;write(2)&lt;/a&gt;). For an ordinary, buffered write, ZFS keeps the data in memory and compresses it seconds later, when it flushes a batch of changes to disk.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl9k3sqjvuju2k2iw91er.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl9k3sqjvuju2k2iw91er.png" alt="Flow chart: write() copies data to memory as dirty data; a transaction group sync at least every 5 seconds, or sooner, compresses each record; if it saved enough it is stored compressed, otherwise it is stored raw with the CPU already spent." width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Compression CPU is spent at transaction group sync, not at &lt;code&gt;write()&lt;/code&gt;, even when the record ends up stored raw.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Step by step:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;write()&lt;/code&gt; copies the data into memory (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zfs_vnops.c#L906-L907" rel="noopener noreferrer"&gt;&lt;code&gt;zfs_vnops.c&lt;/code&gt;&lt;/a&gt;). Data waiting in memory to be written is called dirty data. If dirty data hits its limit, "new writes are halted until space frees up" (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L1366-L1368" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;ZFS writes dirty data out in batches. A batch is a transaction group (txg): changes "written to disk in the syncing state" (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/txg.c#L44-L56" rel="noopener noreferrer"&gt;&lt;code&gt;txg.c&lt;/code&gt;&lt;/a&gt;). Writing one out is called a txg sync. It happens "at least every" &lt;code&gt;zfs_txg_timeout&lt;/code&gt; seconds, 5 by default (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L2397-L2399" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;), and sooner when:

&lt;ul&gt;
&lt;li&gt;dirty data passes 20% of &lt;code&gt;zfs_dirty_data_max&lt;/code&gt; (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L1377-L1379" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;), or&lt;/li&gt;
&lt;li&gt;an admin action waits on it, such as &lt;code&gt;zpool sync&lt;/code&gt; (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man8/zpool-sync.8#L43-L44" rel="noopener noreferrer"&gt;zpool-sync(8)&lt;/a&gt;) or a snapshot (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/txg.c#L101-L107" rel="noopener noreferrer"&gt;&lt;code&gt;txg.c&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;During the sync, &lt;code&gt;zio_write_compress&lt;/code&gt; compresses each dirty record on its own (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c#L1972-L1984" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;The codec gets an output budget (Rule 1 below). If the compressed result doesn't fit, ZFS stores the record uncompressed (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio_compress.c#L147-L150" rel="noopener noreferrer"&gt;&lt;code&gt;zio_compress.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c#L1987-L1990" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A record that doesn't fit wastes the CPU spent on it. Codecs differ in how much they waste:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;lz4 and gzip (on Linux)&lt;/strong&gt; stop as soon as their output overflows the budget (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/lz4_zfs.c#L542-L545" rel="noopener noreferrer"&gt;&lt;code&gt;lz4_zfs.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/os/linux/spl/spl-zlib.c#L120-L124" rel="noopener noreferrer"&gt;&lt;code&gt;spl-zlib.c&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;zstd-3 and higher&lt;/strong&gt; first try a cheap lz4 pass on records of 128 KiB or more. If lz4 fails, they try zstd-1. They give up only if both fail (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L2552-L2558" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zstd/zfs_zstd.c#L556-L598" rel="noopener noreferrer"&gt;&lt;code&gt;zfs_zstd.c&lt;/code&gt;&lt;/a&gt;). On compressible data, that lz4 pass is extra CPU on every write.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two kinds of write don't wait for the next txg sync. ZFS compresses them when the application writes or syncs them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Some sync writes.&lt;/strong&gt; An application calls &lt;code&gt;fsync()&lt;/code&gt;, or opens a file with &lt;code&gt;O_SYNC&lt;/code&gt;, when it needs its data on disk before it carries on (&lt;a href="https://man7.org/linux/man-pages/man2/fsync.2.html" rel="noopener noreferrer"&gt;fsync(2)&lt;/a&gt;, &lt;a href="https://man7.org/linux/man-pages/man2/open.2.html" rel="noopener noreferrer"&gt;open(2)&lt;/a&gt;). ZFS records sync writes in its intent log (ZIL). For some, it writes the data straight into the pool as full records and logs only a pointer to them, which compresses them right away. This happens with &lt;code&gt;logbias=throughput&lt;/code&gt;. On pools without a separate log device, it also happens to most sync writes of 32 KiB or more (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zil.c#L2201-L2234" rel="noopener noreferrer"&gt;&lt;code&gt;zil.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L1760-L1765" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dmu.c#L2060-L2061" rel="noopener noreferrer"&gt;&lt;code&gt;dmu.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zfs_vnops.c#L1459" rel="noopener noreferrer"&gt;&lt;code&gt;zfs_vnops.c&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;O_DIRECT&lt;/code&gt; writes aligned to &lt;code&gt;recordsize&lt;/code&gt;.&lt;/strong&gt; &lt;code&gt;O_DIRECT&lt;/code&gt; is a flag that asks the kernel to minimize caching of a file's I/O (&lt;a href="https://man7.org/linux/man-pages/man2/open.2.html" rel="noopener noreferrer"&gt;open(2)&lt;/a&gt;). By default, such writes bypass ZFS's RAM cache (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L1059-L1081" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;) and go straight to the write pipeline (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dmu_direct.c#L196-L199" rel="noopener noreferrer"&gt;&lt;code&gt;dmu_direct.c&lt;/code&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Two rules decide the real saving
&lt;/h2&gt;

&lt;p&gt;Disks store data in fixed-size sectors. With &lt;code&gt;ashift=12&lt;/code&gt;, the common setting, a sector is 2^12 bytes = 4 KiB. Think of sectors as fixed-size boxes: ZFS compresses each record on its own and stores it in whole boxes, so it can save less than the same codec would on the whole file. Two rules decide how much.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq7jk2ndgwc9klsv5admo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq7jk2ndgwc9klsv5admo.png" alt="A 128 KiB record is 32 sectors. Its budget rounds down to 28 sectors; it compresses to 30,000 bytes (7.3 sectors) and is stored in 8 whole sectors, so 24 are saved and the stored ratio is 4.00x, not 4.37x. An 8 KiB record is 2 sectors; its 87.5% budget of 7 KiB rounds down to 1 sector, so it must compress to 4 KiB, a 50% saving." width="800" height="650"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Both rules at &lt;code&gt;ashift=12&lt;/code&gt;. A 128 KiB record saves 24 of its 32 sectors; an 8 KiB record has to halve to save anything.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 1: a record must save enough.&lt;/strong&gt; ZFS gives the codec a budget of 87.5% of the record (a 12.5% saving), rounded down to whole sectors. If the compressed record doesn't fit, it is stored uncompressed (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c#L1780-L1798" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;budget&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size3"&gt;⌊&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;sector&amp;nbsp;size&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;0.875&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;×&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;record&amp;nbsp;size&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size3"&gt;⌋&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;sectors&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;p&gt;Rounding down hurts small records most. At &lt;code&gt;ashift=12&lt;/code&gt; on ordinary vdevs (single disks, mirrors or RAID-Z groups):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Record size&lt;/th&gt;
&lt;th&gt;Must compress to at most&lt;/th&gt;
&lt;th&gt;Minimum saving&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;128 KiB&lt;/td&gt;
&lt;td&gt;112 KiB&lt;/td&gt;
&lt;td&gt;12.5%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16 KiB&lt;/td&gt;
&lt;td&gt;12 KiB&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8 KiB&lt;/td&gt;
&lt;td&gt;4 KiB&lt;/td&gt;
&lt;td&gt;50%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4 KiB&lt;/td&gt;
&lt;td&gt;112 bytes&lt;/td&gt;
&lt;td&gt;97%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last row is a special case. A 4 KiB record's budget rounds down to zero sectors, so it stays compressed only if it fits in 112 bytes inside its block pointer, the small piece of metadata that records where a block lives. That needs the &lt;code&gt;embedded_data&lt;/code&gt; pool feature, which is on by default, and it never happens on encrypted datasets (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c#L1991-L1993" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zpool-features.7#L547-L563" rel="noopener noreferrer"&gt;zpool-features(7)&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;No tunable changes the 12.5%. A larger &lt;code&gt;ashift&lt;/code&gt; means bigger sectors and coarser rounding. It is set per vdev when the vdev is created or added (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/vdev.c#L1518-L1532" rel="noopener noreferrer"&gt;&lt;code&gt;vdev.c&lt;/code&gt;&lt;/a&gt;), and changing the pool's &lt;code&gt;ashift&lt;/code&gt; property later "will not modify any existing vdev" (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zpoolprops.7#L246-L247" rel="noopener noreferrer"&gt;zpoolprops(7)&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule 2: what's stored is rounded up to whole sectors.&lt;/strong&gt; A record that compresses to 7.3 sectors still takes 8 (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c#L1772-L1778" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;). ZFS counts that padding in the block's size and in &lt;code&gt;compressratio&lt;/code&gt; (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c#L2008-L2015" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;), so &lt;code&gt;compressratio&lt;/code&gt; already includes this loss.&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;stored&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;&lt;span class="delimsizing size3"&gt;⌈&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;sector&amp;nbsp;size&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;compressed&amp;nbsp;size&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;&lt;span class="delimsizing size3"&gt;⌉&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;sectors&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Here are both rules applied to the 128 KiB record in the diagram, with 4 KiB (4,096-byte) sectors:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mtable"&gt;&lt;span class="col-align-r"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;record&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="col-align-l"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;131&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;072&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;bytes&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;32&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;sectors&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;budget&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="arraycolsep"&gt;&lt;/span&gt;&lt;span class="col-align-r"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="minner"&gt;&lt;span class="mopen delimcenter"&gt;⌊&lt;/span&gt;&lt;span class="mord"&gt;0.875&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;×&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;32&lt;/span&gt;&lt;span class="mclose delimcenter"&gt;⌋&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;28&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;sectors&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;compressed&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="col-align-l"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;30&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;000&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;bytes&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≈&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;7.3&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;sectors&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≤&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;28&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;,&amp;nbsp;so&amp;nbsp;it&amp;nbsp;fits&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;stored&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="arraycolsep"&gt;&lt;/span&gt;&lt;span class="col-align-r"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mopen"&gt;⌈&lt;/span&gt;&lt;span class="mord"&gt;7.3&lt;/span&gt;&lt;span class="mclose"&gt;⌉&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;8&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;sectors&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;32&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;768&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;bytes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;The last sector carries 2,768 bytes of padding, which lowers the ratio:&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;30&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;000&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;131&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;072&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;≈&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;4.37&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;×&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;before&amp;nbsp;rounding&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mopen nulldelimiter"&gt;&lt;/span&gt;&lt;span class="mfrac"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;32&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;768&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="frac-line"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;131&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mpunct"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class="mord"&gt;072&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mclose nulldelimiter"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;4.00&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;×&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord text"&gt;&lt;span class="mord"&gt;&amp;nbsp;as&amp;nbsp;stored&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;Rounding can also make different codecs land on the same ratio. gzip-9, zstd-1 and zstd-9 all reported a &lt;code&gt;compressratio&lt;/code&gt; of 4.56× on our JSON logs. We did not inspect each record's stored size, so rounding is only a possible cause.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What the two rules mean in practice: bigger records keep more of the saving.&lt;/strong&gt; Both rules work in whole sectors, so each one costs less than one sector per record. In a 128 KiB record (32 sectors), that is a small loss. In an 8 KiB record (2 sectors), it can be half the record.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2h8soo1s9cgpyddda8gm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2h8soo1s9cgpyddda8gm.png" alt="Grouped bar chart computed from the two rules at ashift=12, assuming every record compresses to the same fraction. Data that compresses 2.5 times, to 40%, where the codec alone would save 60%: saves 0% in 4 KiB records, 50% in 8, 16 and 32 KiB records, 56% at 64 KiB, 59% at 128 KiB and 60% at 1 MiB. Data that compresses 1.5 times, to 67%, where the codec alone would save 33%: saves 0% at 4 and 8 KiB, 25% at 16 and 32 KiB, 31% at 64 and 128 KiB, and 33% at 1 MiB. Footer: small records can lose all of the saving and 1 MiB records keep almost all of it, but a small read still decompresses the whole record, so bigger records cost more per read." width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Same data, different record sizes: small records lose part or all of the codec's saving.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Take data that compresses 2.5×, which the codec alone would shrink by 60%. In 128 KiB records it saves 59% of the disk space. In 8 KiB records it saves 50%, and in 4 KiB records nothing at all. Data that compresses only 1.5× saves nothing below 16 KiB.&lt;/p&gt;

&lt;p&gt;That doesn't mean you should always raise &lt;code&gt;recordsize&lt;/code&gt;. A small read decompresses the whole record, as the next section shows, so bigger records cost more CPU per read. The ZFS docs describe &lt;code&gt;recordsize&lt;/code&gt; as "designed solely for use with database workloads that access files in fixed-size records", and suggest setting it "greater than or equal to the record size of the database" (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L1560-L1573" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;). It can be up to 128 KiB, or up to 16 MiB with the &lt;code&gt;large_blocks&lt;/code&gt; pool feature (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L1576-L1583" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;), and a change "affects only files created afterward" (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7#L1594-L1596" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;In short: data written and read in big pieces keeps more of its saving in large records; data read in small pieces is better served by a &lt;code&gt;recordsize&lt;/code&gt; that matches the application's own record size.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow a read
&lt;/h2&gt;

&lt;p&gt;Writes pay for compression once. Reads can pay for decompression again and again, even when the data never leaves RAM.&lt;/p&gt;

&lt;p&gt;Like most file systems, ZFS keeps recently used data in RAM so repeated reads don't have to go to disk. Its main RAM cache is the ARC. By default, the ARC keeps blocks as they are on disk, compressed (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L150-L156" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L449-L452" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;). That fits more data in RAM. ZFS on Linux 0.7.0 made this the default, and its release notes call the result a larger effective cache (&lt;a href="https://github.com/openzfs/zfs/releases/tag/zfs-0.7.0" rel="noopener noreferrer"&gt;release notes&lt;/a&gt;). The cost is that a block has to be decompressed before it can be used.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb93g1nzsttqstmvieqwf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb93g1nzsttqstmvieqwf.png" alt="Three read paths for a 4 KiB request against a 128 KiB compressed record: an uncompressed copy in RAM, usually in the dbuf cache, copies 4 KiB with no decompression; an ARC hit with only the compressed block decompresses the whole 128 KiB; a disk read caches the compressed block in the ARC, then decompresses the whole 128 KiB." width="800" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For a compressed record, an ARC hit decodes the whole record even when you asked for 4 KiB, unless an uncompressed copy is still in RAM.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Say an application reads 4 KiB from a file. The read takes one of three paths, from cheapest to most expensive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uncompressed copy: no decompression.&lt;/strong&gt; The copy is usually in the dbuf cache, a list of recently used, uncompressed blocks. It was added with compressed ARC "to keep frequently access data uncompressed" (&lt;a href="https://github.com/openzfs/zfs/commit/d3c2ae1c0806b183a315e3d43cc8018cfdca79b5" rel="noopener noreferrer"&gt;commit&lt;/a&gt;), and the read uses it directly (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dbuf.c#L1809-L1830" rel="noopener noreferrer"&gt;&lt;code&gt;dbuf.c&lt;/code&gt;&lt;/a&gt;). The copy can also be another ARC buffer, which ZFS copies (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L2154-L2161" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;But the dbuf cache is small. By default it targets 1/32 of the ARC's &lt;em&gt;current&lt;/em&gt; target size, with no fixed cap (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dbuf.c#L729-L738" rel="noopener noreferrer"&gt;&lt;code&gt;dbuf.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dbuf.c#L231" rel="noopener noreferrer"&gt;&lt;code&gt;dbuf.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4#L62-L65" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ARC hit, compressed: decompress the whole record.&lt;/strong&gt; ZFS turns any byte range into whole blocks (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dmu.c#L517-L521" rel="noopener noreferrer"&gt;&lt;code&gt;dmu.c&lt;/code&gt;&lt;/a&gt;). Then it decompresses each block into a new full-size buffer (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L2834-L2836" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L2154-L2169" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;). Your 4 KiB read decompresses all 128 KiB.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disk read: the same full decompression.&lt;/strong&gt; ZFS keeps the block compressed in the ARC, then decompresses the whole block (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L6205-L6219" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L5663-L5686" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Blocks stored raw skip decompression on every path (&lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c#L2107-L2113" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;In our benchmark, on JSON and event files cached in the ARC, 96–97% of each test's 10,000 random 4 KiB reads decompressed a full 128 KiB record.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before choosing a codec
&lt;/h2&gt;

&lt;p&gt;Two questions do most of the work: how well your data compresses, record by record, and how often you read it back.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4whrkwshg5u8tzen3sfq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4whrkwshg5u8tzen3sfq.png" alt="A 2x2 grid. Across: how often you read the data back, rarely or often. Up: how well it compresses, per record. Compresses well and rarely read: store it small, zstd-1, and test a higher zstd level if capacity is tight, because compression CPU is paid once, at write. Compresses well and read often: balance both, lz4 or zstd-1, because most ARC hits decompress the whole record even for a 4 KiB read; measure read CPU on your own CPUs. Compresses poorly and rarely read: little to gain, lz4 or off, because a record that can't save 12.5% is stored raw with the CPU already spent, and lz4 gives up early. Compresses poorly and read often: reads skip decompression, lz4 or off, because raw records skip decompression but every write still pays for the attempt. Footer: data your database already compresses counts as compressing poorly; then measure on your own hardware." width="800" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Find your data's box.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A checklist to help you decide:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Read/write mix:&lt;/strong&gt; do you write once and rarely read, or read the same data all day? (which means you'd probably want to utilize a cache)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Request size:&lt;/strong&gt; how small are your reads compared with &lt;code&gt;recordsize&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where reads land:&lt;/strong&gt; an uncompressed copy, the ARC or disk?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data:&lt;/strong&gt; how well does it compress, record by record? Does your database already compress it?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CPU:&lt;/strong&gt; how much headroom do you have, and how bursty is the load?&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;OpenZFS source and man pages are pinned to tag &lt;a href="https://github.com/openzfs/zfs/releases/tag/zfs-2.4.1" rel="noopener noreferrer"&gt;&lt;code&gt;zfs-2.4.1&lt;/code&gt;&lt;/a&gt; (upstream). Google Cloud prices are us-east4 on-demand list prices, retrieved 2026-11-16.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Cloud: &lt;a href="https://cloud.google.com/compute/disks-image-pricing" rel="noopener noreferrer"&gt;Disk and image pricing&lt;/a&gt;, &lt;a href="https://docs.cloud.google.com/compute/docs/disks/resize-persistent-disk" rel="noopener noreferrer"&gt;Resize a Persistent Disk&lt;/a&gt;, &lt;a href="https://docs.cloud.google.com/compute/docs/disks/modify-hyperdisks" rel="noopener noreferrer"&gt;Modify a Hyperdisk volume&lt;/a&gt;, &lt;a href="https://docs.cloud.google.com/compute/docs/instances/committed-use-discounts-overview" rel="noopener noreferrer"&gt;Committed use discounts overview&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Elastic, &lt;a href="https://www.elastic.co/docs/reference/elasticsearch/index-settings/index-modules" rel="noopener noreferrer"&gt;Index settings: &lt;code&gt;index.codec&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;PostgreSQL 18, &lt;a href="https://www.postgresql.org/docs/18/storage-toast.html" rel="noopener noreferrer"&gt;TOAST&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Linux man pages: &lt;a href="https://man7.org/linux/man-pages/man2/write.2.html" rel="noopener noreferrer"&gt;write(2)&lt;/a&gt;, &lt;a href="https://man7.org/linux/man-pages/man2/fsync.2.html" rel="noopener noreferrer"&gt;fsync(2)&lt;/a&gt;, &lt;a href="https://man7.org/linux/man-pages/man2/open.2.html" rel="noopener noreferrer"&gt;open(2)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenZFS man pages: &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man8/zpool.8" rel="noopener noreferrer"&gt;zpool(8)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man8/zfs.8" rel="noopener noreferrer"&gt;zfs(8)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man8/zpool-sync.8" rel="noopener noreferrer"&gt;zpool-sync(8)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zfsprops.7" rel="noopener noreferrer"&gt;zfsprops(7)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zpoolprops.7" rel="noopener noreferrer"&gt;zpoolprops(7)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man4/zfs.4" rel="noopener noreferrer"&gt;zfs(4)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zpool-features.7" rel="noopener noreferrer"&gt;zpool-features(7)&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/man/man7/zpoolconcepts.7" rel="noopener noreferrer"&gt;zpoolconcepts(7)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenZFS write path: &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio.c" rel="noopener noreferrer"&gt;&lt;code&gt;zio.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zio_compress.c" rel="noopener noreferrer"&gt;&lt;code&gt;zio_compress.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zfs_vnops.c" rel="noopener noreferrer"&gt;&lt;code&gt;zfs_vnops.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/txg.c" rel="noopener noreferrer"&gt;&lt;code&gt;txg.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dmu_direct.c" rel="noopener noreferrer"&gt;&lt;code&gt;dmu_direct.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/lz4_zfs.c" rel="noopener noreferrer"&gt;&lt;code&gt;lz4_zfs.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/os/linux/spl/spl-zlib.c" rel="noopener noreferrer"&gt;&lt;code&gt;spl-zlib.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zstd/zfs_zstd.c" rel="noopener noreferrer"&gt;&lt;code&gt;zfs_zstd.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/spa_misc.c" rel="noopener noreferrer"&gt;&lt;code&gt;spa_misc.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/zil.c" rel="noopener noreferrer"&gt;&lt;code&gt;zil.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/vdev.c" rel="noopener noreferrer"&gt;&lt;code&gt;vdev.c&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenZFS read path: &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/arc.c" rel="noopener noreferrer"&gt;&lt;code&gt;arc.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dbuf.c" rel="noopener noreferrer"&gt;&lt;code&gt;dbuf.c&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openzfs/zfs/blob/zfs-2.4.1/module/zfs/dmu.c" rel="noopener noreferrer"&gt;&lt;code&gt;dmu.c&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenZFS, &lt;a href="https://github.com/openzfs/zfs/commit/d3c2ae1c0806b183a315e3d43cc8018cfdca79b5" rel="noopener noreferrer"&gt;compressed ARC and dbuf cache commit&lt;/a&gt; and &lt;a href="https://github.com/openzfs/zfs/releases/tag/zfs-0.7.0" rel="noopener noreferrer"&gt;0.7.0 release notes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Our benchmark (events 3.20× and 3.01×, JSON 4.56×, 96–97% of random ARC reads decompressing a record): ZFS 2.4.1 on Google Cloud VMs, runs of 2026-10-30 and 31. Raw data is not published.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>zfs</category>
      <category>cloud</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
