In recent thread on the list (see: "abysmal performance"), there were some questions regarding why Btrfs seems to break up compressed files into 32 block (128KB) chunks. This is done for two reasons: (1) Ease the RAM required when spreading compression across several CPUs. (2) Make sure the amount of IO required to do a random read is reasonably small. The two attached patches show how to increase limit to 512KB (128 blocks). I''m submitting these patches more for the purpose of documenting this issue on the M/L. I haven''t fully explored the effect on performance. As Chris Mason pointed out in the referenced thread, you would have to decompress 512KB instead of just 128KB if you have a random read of 1KB in the middle of one of the chunks. It should also be noted that just because filefrag reports the file as fragmented, the extent fragments are often adjacent on the storage medium (especially if you''ve just run defragment on that file). It''s possible that system performance could improve if the chunk size was even smaller perhaps, instead of larger. However, I have seen a decrease in the size of Metadata on my compressed file systems after applying this patch, and defragmenting files with the larger extent size. Since I''d already done the experiment, and since someone was asking about it, I thought I''d share my findings. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Mitch Harder
2011-May-03 19:28 UTC
[PATCH 1/2] [RFC] Btrfs: Increase limit on size of compressed extent
The size of compressed extents was limited to 128K, which leads to fragmentation of the extents (although the extents themselves may still be located contiguously). This limit is put in place to ease the RAM required when spreading compression across several CPUs, and to make sure the amount of IO required to do a random read is reasonably small. Increase this limit to 512K. --- fs/btrfs/inode.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 870869a..7ef2b34 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -333,8 +333,8 @@ static noinline int compress_file_range(struct inode *inode, unsigned long nr_pages_ret = 0; unsigned long total_compressed = 0; unsigned long total_in = 0; - unsigned long max_compressed = 128 * 1024; - unsigned long max_uncompressed = 128 * 1024; + unsigned long max_compressed = 512 * 1024; + unsigned long max_uncompressed = 512 * 1024; int i; int will_compress; int compress_type = root->fs_info->compress_type; @@ -343,7 +343,7 @@ static noinline int compress_file_range(struct inode *inode, again: will_compress = 0; nr_pages = (end >> PAGE_CACHE_SHIFT) - (start >> PAGE_CACHE_SHIFT) + 1; - nr_pages = min(nr_pages, (128 * 1024UL) / PAGE_CACHE_SIZE); + nr_pages = min(nr_pages, (512 * 1024UL) / PAGE_CACHE_SIZE); /* * we don''t want to send crud past the end of i_size through @@ -368,7 +368,7 @@ again: * * We also want to make sure the amount of IO required to do * a random read is reasonably small, so we limit the size of - * a compressed extent to 128k. + * a compressed extent to 512k (was 128k). */ total_compressed = min(total_compressed, max_uncompressed); num_bytes = (end - start + blocksize) & ~(blocksize - 1); -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Mitch Harder
2011-May-03 19:28 UTC
[PATCH 2/2] [RFC] Btrfs: Increase limit of relocated extent size
The size of relocated compressed extents was limited to 128K. This limit is put in place to ease the RAM required when spreading compression across several CPUs, and to make sure the amount of IO required to do a random read is reasonably small. Increase this limit to 512K. --- fs/btrfs/relocation.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 58250e0..dd17a35 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -143,7 +143,7 @@ struct tree_block { unsigned int key_ready:1; }; -#define MAX_EXTENTS 128 +#define MAX_EXTENTS 512 struct file_extent_cluster { u64 start; -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html