vinyl: read iterator: do not fetch statements found in the cache
When the read iterator stops reading a chain of statements from the cache it advances all other sources by calling next_key() until the last_stmt is reached. This effectively cancels the benefit of using the cache, because all statements skipped due to the cache are fetched from in-memory trees or, even worse, on-disk runs. To fix this, let's introduce and use skip() method which makes the source iterator jump to the first statement following a particular key. Its implementation is similar to and reuses the code from start and restore procedures. With this new method, we don't need to mangle iterator_type/key when reopening source iterators during restoration so that they start iteration from last_stmt: instead we can advance them with skip() on the first iteration. Let's do this too, because the iterator can benefit from knowing the real iterator type (e.g. cache can stop ITER_EQ iteration even if there's no chain in the cache, by looking at vy_cache_entry::left_boundary_level,right_boundary_level).
Showing
- src/box/vy_cache.c 91 additions, 21 deletionssrc/box/vy_cache.c
- src/box/vy_cache.h 9 additions, 0 deletionssrc/box/vy_cache.h
- src/box/vy_mem.c 43 additions, 2 deletionssrc/box/vy_mem.c
- src/box/vy_mem.h 9 additions, 0 deletionssrc/box/vy_mem.h
- src/box/vy_read_iterator.c 64 additions, 88 deletionssrc/box/vy_read_iterator.c
- src/box/vy_run.c 57 additions, 22 deletionssrc/box/vy_run.c
- src/box/vy_run.h 9 additions, 0 deletionssrc/box/vy_run.h
- src/box/vy_tx.c 53 additions, 13 deletionssrc/box/vy_tx.c
- src/box/vy_tx.h 8 additions, 0 deletionssrc/box/vy_tx.h
Loading
Please register or sign in to comment