[patches] [PATCH 2/2] vinyl: implement space.bsize, index.bsize, and index.len

Vladimir Davydov vdavydov.dev at gmail.com
Sat Feb 10 22:37:01 MSK 2018

On Sat, Feb 10, 2018 at 09:35:06PM +0300, Konstantin Osipov wrote:
> * Vladimir Davydov <vdavydov.dev at gmail.com> [18/02/04 21:12]:
> I checked the docs and found a different way to explain what
> looked wrong.
> >  static size_t
> >  vinyl_space_bsize(struct space *space)
> >  {
> > -	(void)space;
> > -	return 0;
> > +	struct index *pk_base = space_index(space, 0);
> > +	if (pk_base == NULL)
> > +		return 0;
> > +	struct vy_index *pk = vy_index(pk_base);
> > +	return pk->stat.memory.count.bytes + pk->stat.disk.count.bytes;
> > +}
> > +
> > +static ssize_t
> > +vinyl_index_size(struct index *base)
> > +{
> > +	struct vy_index *index = vy_index(base);
> > +	return index->stat.memory.count.rows + index->stat.disk.count.rows;
> >  }
> As far as I can see, in your implementation, primary key bsize is
> the same as space bsize().

No. Space bsize is the binary size of user data stored in the space
while index bsize is the price paid for indexing data, and space.bsize
is not equal to index.bsize, neither for primary nor secondary index.

( note, vinyl_index_size(), which you're quoting above, is index.len(),
  it has nothing to do with index.bsize() )

In the current version of this patch set, index bsize equals the total
size of page indexes, bloom filters, and memory tree extents used by the
index, no matter if the index is primary or secondary, but I think in
case of secondary indexes, it would make sense to account tuples stored
on disk there as well, because they exist solely for indexing data
stored in pk.

> According to the docs, bsize() of the
> space is binary footprint of data, bsize of index is how much
> space an index itself takes, not accounting the data.

Quoting the doc here:

    Number of bytes in the space.
    Return the total number of bytes taken by the index.

I don't see any contradiction with what I'm trying to implement here and
what I'm trying to tell you all along.

> The total sum of space bsize() and index bsize() for all defined
> indexes provides you an estimate of how much memory is used by a
> space - be it in RAM or on disk.

In my previous e-mail I tried to explain why it doesn't work in case of
vinyl. Please read it in case you've missed it.

> Please let's stick to this both in memtx and in vinyl.

More information about the Tarantool-patches mailing list