Linux developer Usama Arif has discovered and addressed an inefficiency in the Btrfs file system's Zstd decompression code, resulting in performance improvements. The fix, queued for inclusion in the Linux 7.4 kernel cycle, reduces redundant data writing during decompression.
Currently, the Btrfs Zstd decompression path writes every delivered byte twice. According to Arif, "zstd_decompress_bio() gives zstd a sectorsize-sized scratch buffer, and btrfs_decompress_buf2page() then copies the part overlapping the read bio into the destination folios. Every delivered byte is written twice." The proposed solution bypasses this duplication by choosing the output buffer per streaming call and utilizing `zstd_map_dest()` to map the destination directly to the page cache.
Testing indicates a 7.8% reduction in sequential read time with 4K sector sizes, 3.6% with 16K sectors, and 6.8% with 64K sectors. Random 4K reads also saw an improvement of approximately 3% when using Btrfs with Zstd compression enabled. The patch is currently in the "for-next" branch and is expected to be included in the Linux 7.4 kernel release, scheduled for October. Developers also hope to include other Zstd kernel improvements in the same release.
Read the original coverage
💬 Comments
📜 Comment Policy