[Btrfs-devel] Compression?

Chris Mason chris.mason at oracle.com
Thu Jul 5 05:56:38 PDT 2007


On Wed, 4 Jul 2007 11:07:10 +0100
Steve Long <slong at rathaus.eclipse.co.uk> wrote:

> > There are two kinds of file extents, inline and external.  Inline
> > extents have their data directly in the btree (actually just at the
> > end of the extent item) and external extents have their data in
> > separate extents on disk.
> >
> > A few bits of the type field could be used to indicate if the data
> > in the extent is compressed or not.  If it is compressed, the
> > extent item would need an extra field to store the actual
> > uncompressed length of the data it contains.
> 
> Sounds cool; inline extents wouldn't be compressed as the amount of
> data is small?

Actually, we would probably gain the most from compressing the inline
extents because it compacts the btree.  Anything that saves space in
the btree makes searches more IO efficient.

I've always wondered if compressed directory leaves would make things
faster...the added complexity is actually much easier to manage than
compressed files.

> Also, I am unsure why more than 1 bit is required to
> indicate compression.

1 bit is enough, but there may be other similar flags we want to store.

> Having only external extent items compressed
> would be good for performance on small files (the reason for internal
> extents aiui) and would also mean less space usage.
> 
> I guess you could have a heuristic to compress smaller files if it
> would make them fit in an inline extent as well (ie only if needed.)

Right, there are a number of policies that make sense.

-chris



More information about the Btrfs-devel mailing list