public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* Sequential read(8K) from compressed files are very slow
@ 2025-06-03 19:56 Dimitrios Apostolou
  2025-06-04  1:36 ` Boris Burkov
  0 siblings, 1 reply; 8+ messages in thread
From: Dimitrios Apostolou @ 2025-06-03 19:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Qu Wenruo, Christoph Hellwig, Anand Jain

Hello list,

I notice consistently that sequential reads from compressed files are slow 
when the block size is small.

It's extremely easy to reproduce, but the problem is I can't find the 
bottleneck. I suspect it is an issue of Btrfs, not doing read-ahead like 
it does with non-compressed files.

Can you reproduce it? I'd also appreciate instructions for further 
debugging it. Or tweaking my system to improve the case.

I'm CC'ing people from previous related discussion at
https://www.spinics.net/lists/linux-btrfs/msg137840.html


** How to reproduce:

Filesystem is newly created with btrfs-progs v6.6.3, on NVMe drive with 
1.5TB of space, mounted with compress=zstd:3. Kernel version is 6.11.


1. create 10GB compressible and incompressible files

head -c 10G /dev/zero          > highly-compressible
head -c 10G <(od /dev/urandom) > compressible
head -c 10G /dev/urandom       > incompressible


2. Verify they are indeed what promised

$ sudo compsize highly-compressible
Processed 1 file, 81920 regular extents (81920 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL        3%      320M          10G          10G
$ sudo compsize compressible
Processed 1 file, 81965 regular extents (81965 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL       43%      4.3G          10G          10G
zstd        43%      4.3G          10G          10G
$ sudo compsize incompressible
Processed 1 file, 80 regular extents (80 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL      100%       10G          10G          10G
none       100%       10G          10G          10G


3. Measure read() speed with 8KB block size

$ sync
$ echo 1 | sudo tee /proc/sys/vm/drop_caches

$ dd if=highly-compressible   of=/dev/null bs=8k
1310720+0 records in
1310720+0 records out
10737418240 bytes (11 GB, 10 GiB) copied, 12.9102 s, 832 MB/s

$ dd if=compressible   of=/dev/null bs=8k
1310720+0 records in
1310720+0 records out
10737418240 bytes (11 GB, 10 GiB) copied, 30.68 s, 350 MB/s

$ dd if=incompressible   of=/dev/null bs=8k
1310720+0 records in
1310720+0 records out
10737418240 bytes (11 GB, 10 GiB) copied, 3.85749 s, 2.8 GB/s


The above results are repeatable. The device can give several GB/s like in 
the last case, so I would expect such high numbers or up to what the CPU 
can decompress. But CPU cores utilisation is low, so I have excluded that 
from being the bottleneck.


What do you think?
Dimitris


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-07  0:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 19:56 Sequential read(8K) from compressed files are very slow Dimitrios Apostolou
2025-06-04  1:36 ` Boris Burkov
2025-06-04  6:22   ` Christoph Hellwig
2025-06-04 18:03     ` Boris Burkov
2025-06-04 21:49       ` Boris Burkov
2025-06-05  4:35         ` Christoph Hellwig
2025-06-05 17:09       ` Dimitrios Apostolou
2025-06-07  0:37         ` Boris Burkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox