From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 15 May 2018 18:00:50 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] Re: [PATCH 09/12] vinyl: consolidate skip optimization checks in read iterator Message-ID: <20180515150050.rkcav2rcrmfdwng7@esperanza> References: <5ff19cf39854cc565022683b6dce48aeda904d2f.1523820298.git.vdavydov.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: Vladislav Shpilevoy Cc: tarantool-patches@freelists.org, kostja@tarantool.org List-ID: 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);