[tarantool-patches] Re: [PATCH 09/12] vinyl: consolidate skip optimization checks in read iterator

Vladimir Davydov vdavydov.dev at gmail.com
Tue May 15 18:00:50 MSK 2018


On Mon, May 14, 2018 at 09:25:45PM +0300, Vladislav Shpilevoy wrote:
> 1. Old skip functions had returned their last_stmt (itr->last_stmt), that
> updates their current statement (itr->curr_stmt). This was done if an iterator
> is not 'behind' according to the new terminology. But now if an iterator is
> behind, it does nothing and does not update itr->curr_stmt as well.

If a source iterator is behind the current read iterator position,
'skip' method will update src_itr->curr_stmt, just like before.
Otherwise, there's no need to update src_itr->curr_stmt, because
the position is up-to-date as the source was not skipped at the
previous iteration, neither was it restored. All we need to do in
this case is move the source to the next key provided it was used
at the previous iteration.

> 
> 2. Old vy_cache_iterator_skip in the non-behind state could set 'stop'
> flag triggering skipped_src propagation, but now if cache is not behind,
> stop flag is always false, and skipped_src is not propagated.

If the cache iterator is up-to-date with the current read iterator
position (not behind), its 'skip' method is not called, but it still can
(and does) set the 'stop' flag in the 'next_key' method.

> 
> 3. vy_read_iterator_scan_txw does not use vy_read_src_is_behind() - it
> continues old way usage:
> if (!src->is_started)
> 	vy_txw_iterator_skip(src_itr, itr->last_stmt, &src->stmt);

Because txw iterator cannot be behind the current position (skipped),
and there's an assertion for this in vy_read_iterator_scan_txw():

	assert(itr->txw_src < itr->skipped_src);



More information about the Tarantool-patches mailing list