Skip to contentSkip to conversation

Compression of large files

DISCUSSION Atila Romero 2 participants 2 messages May 27, 2009 Btrfs file system

lore
Share & tools
lore
#0 lore raw

During a file write, if the compression doesn't proves to be economical to a portion of the file, the whole file is marked as nocompress, and subsequent writes don't use compression at all. This can be seen as a feature, as it saves CPU in files like videos. But if the file is a dd image of a disk, or other types of large files, this behavior is undesirable, since different portions of the file will have different compression ratios.
I only became aware of this after searching the source code, after spending some hours trying to find out why the compression wasn't working. This can be a really unexpected behavior for a end user who is looking for compression.
The specific part of the code is at inode.c:
477 <#l477>

                /* flag the file so we don't compress in the future */

478 <#l478> btrfs_set_flag(inode, NOCOMPRESS);

How about commenting line 478?

Atila

#1 lore raw
Quoted 13 lines · Atila Romero

During a file write, if the compression doesn't proves to be economical to a portion of the file, the whole file is marked as nocompress, and subsequent writes don't use compression at all. This can be seen as a feature, as it saves CPU in files like videos. But if the file is a dd image of a disk, or other types of large files, this behavior is undesirable, since different portions of the file will have different compression ratios.
I only became aware of this after searching the source code, after spending some hours trying to find out why the compression wasn't working. This can be a really unexpected behavior for a end user who is looking for compression.
The specific part of the code is at inode.c:
477 <#l477>

Quoted 4 lines
                /* flag the file so we don't compress in the future */

478 <#l478> btrfs_set_flag(inode, NOCOMPRESS);

How about commenting line 478?

The plan is to add a flag for the file to make it always compress even when parts of the file do not compress well.

-chris