Daniel Phillips | 1 Oct 23:07

Thinking about losing the dleaf free space vars

Currently we have:

	unsigned leaf_free(BTREE, vleaf *leaf)
	{
		return to_dleaf(leaf)->used - to_dleaf(leaf)->free;
	}

and the same result is produced by:

	int leaf_free2(BTREE, void *vleaf)
	{
		struct dleaf *leaf = vleaf;
		struct group *gdict = (void *)leaf + btree->sb->blocksize, *gstop = gdict - leaf->groups;
		struct entry *edict = (void *)gstop, *entry = edict;
		struct extent *extents = leaf->table;
		for (struct group *group = gdict - 1; group >= gstop; group--)
			extents += (entry -= group->count)->limit;
		return (void *)entry - (void *)extents;
	}

Which is pretty efficient.  I wonder whether it is worth maintaining
the free/used variables in the dleaf at all?  There are only two places
where we actually need to know: in filemap.c, to decide whether we need
to split the leaf before inserting new extents, and in btree.c to
decide whether we can merge two leaves.  In both cases we have just
traversed the leaf contents anyway, and done most of the work of
computing the leaf free space.

Against this, we have a considerable amount of code for maintaining the
free and used variables in the leaf during various operations.  I have
(Continue reading)

Shapor Naghibzadeh | 1 Oct 23:53
Picon
Gravatar

Re: Thinking about losing the dleaf free space vars

I think at this point the tracking used/free explicitly will make
detecting bugs easier.  Perhaps it should be left for now, and removed
later as an optimization.

Shapor

On Wed, Oct 1, 2008 at 2:07 PM, Daniel Phillips <phillips <at> phunq.net> wrote:
> Currently we have:
>
>        unsigned leaf_free(BTREE, vleaf *leaf)
>        {
>                return to_dleaf(leaf)->used - to_dleaf(leaf)->free;
>        }
>
> and the same result is produced by:
>
>        int leaf_free2(BTREE, void *vleaf)
>        {
>                struct dleaf *leaf = vleaf;
>                struct group *gdict = (void *)leaf + btree->sb->blocksize, *gstop = gdict - leaf->groups;
>                struct entry *edict = (void *)gstop, *entry = edict;
>                struct extent *extents = leaf->table;
>                for (struct group *group = gdict - 1; group >= gstop; group--)
>                        extents += (entry -= group->count)->limit;
>                return (void *)entry - (void *)extents;
>        }
>
> Which is pretty efficient.  I wonder whether it is worth maintaining
> the free/used variables in the dleaf at all?  There are only two places
> where we actually need to know: in filemap.c, to decide whether we need
(Continue reading)


Gmane