diff --git a/src/box/vinyl.c b/src/box/vinyl.c index e05f6ea6880b4aa0cf71aa580af07476e703e5f4..17f0c6af1afeed3b4f3106ffc7cf7ac3d1f7516d 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -232,8 +232,6 @@ struct vy_stat { /* iterators statistics */ struct vy_iterator_stat txw_stat; struct vy_iterator_stat cache_stat; - struct vy_iterator_stat mem_stat; - struct vy_iterator_stat run_stat; }; static struct vy_stat * @@ -4485,8 +4483,6 @@ vy_info_append_performance(struct vy_env *env, struct info_handler *h) info_table_begin(h, "iterator"); vy_info_append_iterator_stat(h, "txw", &stat->txw_stat); vy_info_append_iterator_stat(h, "cache", &stat->cache_stat); - vy_info_append_iterator_stat(h, "mem", &stat->mem_stat); - vy_info_append_iterator_stat(h, "run", &stat->run_stat); info_table_end(h); info_table_end(h); @@ -4506,22 +4502,26 @@ static void vy_info_append_stmt_counter(struct info_handler *h, const char *name, const struct vy_stmt_counter *count) { - info_table_begin(h, name); + if (name != NULL) + info_table_begin(h, name); info_append_int(h, "rows", count->rows); info_append_int(h, "bytes", count->bytes); - info_table_end(h); + if (name != NULL) + info_table_end(h); } static void vy_info_append_disk_stmt_counter(struct info_handler *h, const char *name, const struct vy_disk_stmt_counter *count) { - info_table_begin(h, name); + if (name != NULL) + info_table_begin(h, name); info_append_int(h, "rows", count->rows); info_append_int(h, "bytes", count->bytes); info_append_int(h, "bytes_compressed", count->bytes_compressed); info_append_int(h, "pages", count->pages); - info_table_end(h); + if (name != NULL) + info_table_end(h); } void @@ -4531,20 +4531,43 @@ vy_index_info(struct vy_index *index, struct info_handler *h) struct vy_index_stat *stat = &index->stat; info_begin(h); + info_append_int(h, "rows", stat->disk.count.rows + stat->memory.count.rows); info_append_int(h, "bytes", stat->disk.count.bytes + stat->memory.count.bytes); - vy_info_append_stmt_counter(h, "memory", &stat->memory.count); - vy_info_append_disk_stmt_counter(h, "disk", &stat->disk.count); - info_append_int(h, "range_size", index->opts.range_size); - info_append_int(h, "page_size", index->opts.page_size); + + info_table_begin(h, "memory"); + vy_info_append_stmt_counter(h, NULL, &stat->memory.count); + info_table_begin(h, "iterator"); + info_append_int(h, "lookup", stat->memory.iterator.lookup); + vy_info_append_stmt_counter(h, "get", &stat->memory.iterator.get); + info_table_end(h); + info_table_end(h); + + info_table_begin(h, "disk"); + vy_info_append_disk_stmt_counter(h, NULL, &stat->disk.count); + info_table_begin(h, "iterator"); + info_append_int(h, "lookup", stat->disk.iterator.lookup); + vy_info_append_stmt_counter(h, "get", &stat->disk.iterator.get); + vy_info_append_disk_stmt_counter(h, "read", &stat->disk.iterator.read); + info_table_begin(h, "bloom"); + info_append_int(h, "hit", stat->disk.iterator.bloom_hit); + info_append_int(h, "miss", stat->disk.iterator.bloom_miss); + info_table_end(h); + info_table_end(h); + info_table_end(h); + info_append_int(h, "range_count", index->range_count); info_append_int(h, "run_count", index->run_count); info_append_int(h, "run_avg", index->run_count / index->range_count); histogram_snprint(buf, sizeof(buf), index->run_hist); info_append_str(h, "run_histogram", buf); + info_append_double(h, "bloom_fpr", index->opts.bloom_fpr); + info_append_int(h, "range_size", index->opts.range_size); + info_append_int(h, "page_size", index->opts.page_size); + info_end(h); } @@ -7656,22 +7679,23 @@ static void vy_read_iterator_add_mem(struct vy_read_iterator *itr) { struct vy_index *index = itr->index; - struct vy_iterator_stat *stat = &index->env->stat->mem_stat; struct vy_merge_src *sub_src; /* Add the active in-memory index. */ assert(index->mem != NULL); sub_src = vy_merge_iterator_add(&itr->merge_iterator, true, false); - vy_mem_iterator_open(&sub_src->mem_iterator, stat, index->mem, - itr->iterator_type, itr->key, + vy_mem_iterator_open(&sub_src->mem_iterator, + &index->stat.memory.iterator, + index->mem, itr->iterator_type, itr->key, itr->read_view, itr->curr_stmt); /* Add sealed in-memory indexes. */ struct vy_mem *mem; rlist_foreach_entry(mem, &index->sealed, in_sealed) { sub_src = vy_merge_iterator_add(&itr->merge_iterator, false, false); - vy_mem_iterator_open(&sub_src->mem_iterator, stat, mem, - itr->iterator_type, itr->key, + vy_mem_iterator_open(&sub_src->mem_iterator, + &index->stat.memory.iterator, + mem, itr->iterator_type, itr->key, itr->read_view, itr->curr_stmt); } } @@ -7681,7 +7705,6 @@ vy_read_iterator_add_disk(struct vy_read_iterator *itr) { assert(itr->curr_range != NULL); struct vy_index *index = itr->index; - struct vy_iterator_stat *stat = &index->env->stat->run_stat; struct tuple_format *format; struct vy_slice *slice; /* @@ -7708,7 +7731,8 @@ vy_read_iterator_add_disk(struct vy_read_iterator *itr) assert(slice->run->info.max_lsn <= index->dump_lsn); struct vy_merge_src *sub_src = vy_merge_iterator_add( &itr->merge_iterator, false, true); - vy_run_iterator_open(&sub_src->run_iterator, coio_read, stat, + vy_run_iterator_open(&sub_src->run_iterator, coio_read, + &index->stat.disk.iterator, &index->env->run_env, slice, itr->iterator_type, itr->key, itr->read_view, index->key_def, diff --git a/src/box/vy_mem.c b/src/box/vy_mem.c index fa37a597e8d44c9a5a64404af841259c100c1a0b..215a64749a2659c6b4d767f7f580f4cb8f446666 100644 --- a/src/box/vy_mem.c +++ b/src/box/vy_mem.c @@ -268,8 +268,11 @@ vy_mem_iterator_copy_to(struct vy_mem_iterator *itr, struct tuple **ret) tuple_unref(itr->last_stmt); itr->last_stmt = vy_stmt_dup(itr->curr_stmt, tuple_format(itr->curr_stmt)); *ret = itr->last_stmt; - if (itr->last_stmt != NULL) + if (itr->last_stmt != NULL) { + itr->stat->get.rows++; + itr->stat->get.bytes += tuple_size(*ret); return 0; + } return -1; } @@ -291,7 +294,6 @@ static int vy_mem_iterator_step(struct vy_mem_iterator *itr, enum iterator_type iterator_type) { - itr->stat->step_count++; if (iterator_type == ITER_LE || iterator_type == ITER_LT) vy_mem_tree_iterator_prev(&itr->mem->tree, &itr->curr_pos); else @@ -360,7 +362,7 @@ vy_mem_iterator_start_from(struct vy_mem_iterator *itr, const struct tuple *key) { assert(! itr->search_started); - itr->stat->lookup_count++; + itr->stat->lookup++; itr->version = itr->mem->version; itr->search_started = true; @@ -465,7 +467,7 @@ vy_mem_iterator_check_version(struct vy_mem_iterator *itr) static const struct vy_stmt_iterator_iface vy_mem_iterator_iface; void -vy_mem_iterator_open(struct vy_mem_iterator *itr, struct vy_iterator_stat *stat, +vy_mem_iterator_open(struct vy_mem_iterator *itr, struct vy_mem_iterator_stat *stat, struct vy_mem *mem, enum iterator_type iterator_type, const struct tuple *key, const struct vy_read_view **rv, struct tuple *before_first) diff --git a/src/box/vy_mem.h b/src/box/vy_mem.h index ff9ffbc6a1d0b15c6ce0259fb77f154b08e9c155..4e8df5b66d23e39d4bd9cafd52d4a3510b8d4092 100644 --- a/src/box/vy_mem.h +++ b/src/box/vy_mem.h @@ -306,7 +306,7 @@ struct vy_mem_iterator { struct vy_stmt_iterator base; /** Usage statistics */ - struct vy_iterator_stat *stat; + struct vy_mem_iterator_stat *stat; /* mem */ struct vy_mem *mem; @@ -355,7 +355,7 @@ struct vy_mem_iterator { * Open the iterator. */ void -vy_mem_iterator_open(struct vy_mem_iterator *itr, struct vy_iterator_stat *stat, +vy_mem_iterator_open(struct vy_mem_iterator *itr, struct vy_mem_iterator_stat *stat, struct vy_mem *mem, enum iterator_type iterator_type, const struct tuple *key, const struct vy_read_view **rv, struct tuple *before_first); diff --git a/src/box/vy_run.c b/src/box/vy_run.c index 783ae97e5e70e784aa7e9b8249da52c4b7477b06..75c20361680d152388174ba47941932dd614f8de 100644 --- a/src/box/vy_run.c +++ b/src/box/vy_run.c @@ -1024,6 +1024,12 @@ vy_run_iterator_load_page(struct vy_run_iterator *itr, uint32_t page_no, /* Update cache */ vy_run_iterator_cache_put(itr, page, page_no); + /* Update read statistics. */ + itr->stat->read.rows += page_info->row_count; + itr->stat->read.bytes += page_info->unpacked_size; + itr->stat->read.bytes_compressed += page_info->size; + itr->stat->read.pages++; + *result = page; return 0; } @@ -1140,7 +1146,6 @@ vy_run_iterator_next_pos(struct vy_run_iterator *itr, struct vy_run_iterator_pos *pos) { struct vy_run *run = itr->slice->run; - itr->stat->step_count++; *pos = itr->curr_pos; assert(pos->page_no < run->info.page_count); if (iterator_type == ITER_LE || iterator_type == ITER_LT) { @@ -1311,8 +1316,8 @@ vy_run_iterator_start_from(struct vy_run_iterator *itr, *ret = NULL; const struct key_def *user_key_def = itr->user_key_def; - if (run->info.has_bloom && iterator_type == ITER_EQ && - tuple_field_count(key) >= user_key_def->part_count) { + bool is_full_key = (tuple_field_count(key) >= user_key_def->part_count); + if (run->info.has_bloom && iterator_type == ITER_EQ && is_full_key) { uint32_t hash; if (vy_stmt_type(key) == IPROTO_SELECT) { const char *data = tuple_data(key); @@ -1323,12 +1328,12 @@ vy_run_iterator_start_from(struct vy_run_iterator *itr, } if (!bloom_possible_has(&run->info.bloom, hash)) { itr->search_ended = true; - itr->stat->bloom_reflections++; + itr->stat->bloom_hit++; return 0; } } - itr->stat->lookup_count++; + itr->stat->lookup++; if (run->info.page_count == 1) { /* there can be a stupid bootstrap run in which it's EOF */ @@ -1367,6 +1372,8 @@ vy_run_iterator_start_from(struct vy_run_iterator *itr, if (iterator_type == ITER_EQ && !equal_found) { vy_run_iterator_cache_clean(itr); itr->search_ended = true; + if (run->info.has_bloom && is_full_key) + itr->stat->bloom_miss++; return 0; } if ((iterator_type == ITER_GE || iterator_type == ITER_GT) && @@ -1476,7 +1483,7 @@ static struct vy_stmt_iterator_iface vy_run_iterator_iface; */ void vy_run_iterator_open(struct vy_run_iterator *itr, bool coio_read, - struct vy_iterator_stat *stat, struct vy_run_env *run_env, + struct vy_run_iterator_stat *stat, struct vy_run_env *run_env, struct vy_slice *slice, enum iterator_type iterator_type, const struct tuple *key, const struct vy_read_view **rv, const struct key_def *key_def, @@ -1544,6 +1551,8 @@ vy_run_iterator_get(struct vy_run_iterator *itr, struct tuple **result) if (rc == 0) { itr->curr_stmt_pos = itr->curr_pos; itr->curr_stmt = *result; + itr->stat->get.rows++; + itr->stat->get.bytes += tuple_size(*result); } return rc; } diff --git a/src/box/vy_run.h b/src/box/vy_run.h index 53efb86c3f12f48d05bad03f6d40e7c25030170a..9a79bf41b11c3b3231c232e9091100c8cdf7402e 100644 --- a/src/box/vy_run.h +++ b/src/box/vy_run.h @@ -206,7 +206,7 @@ struct vy_run_iterator { /** Parent class, must be the first member */ struct vy_stmt_iterator base; /** Usage statistics */ - struct vy_iterator_stat *stat; + struct vy_run_iterator_stat *stat; /** Vinyl run environment. */ struct vy_run_env *run_env; @@ -437,7 +437,7 @@ vy_slice_cut(struct vy_slice *slice, int64_t id, void vy_run_iterator_open(struct vy_run_iterator *itr, bool coio_read, - struct vy_iterator_stat *stat, struct vy_run_env *run_env, + struct vy_run_iterator_stat *stat, struct vy_run_env *run_env, struct vy_slice *slice, enum iterator_type iterator_type, const struct tuple *key, const struct vy_read_view **rv, const struct key_def *key_def, diff --git a/src/box/vy_stat.h b/src/box/vy_stat.h index 8abc59ee4eb2a44d34b548a74c16d72d0329697d..91e8b8a6bf9eea5e81333fdc25b2191242b614b3 100644 --- a/src/box/vy_stat.h +++ b/src/box/vy_stat.h @@ -57,17 +57,54 @@ struct vy_disk_stmt_counter { int64_t pages; }; +/** Memory iterator statistics. */ +struct vy_mem_iterator_stat { + /** Number of lookups in the memory tree. */ + int64_t lookup; + /** Number of statements returned by the iterator. */ + struct vy_stmt_counter get; +}; + +/** Run iterator statistics. */ +struct vy_run_iterator_stat { + /** Number of lookups in the page index. */ + int64_t lookup; + /** Number of statements returned by the iterator. */ + struct vy_stmt_counter get; + /** + * Number of times the bloom filter allowed to + * avoid a disk read. + */ + int64_t bloom_hit; + /** + * Number of times the bloom filter failed to + * prevent a disk read. + */ + int64_t bloom_miss; + /** + * Number of statements actually read from the disk. + * It may be greater than the number of statements + * returned by the iterator, because of page granularity + * of disk reads. + */ + struct vy_disk_stmt_counter read; +}; + /** Vinyl index statistics. */ struct vy_index_stat { /** Memory related statistics. */ struct { /** Number of statements stored in memory. */ struct vy_stmt_counter count; + /** Memory iterator statistics. */ + struct vy_mem_iterator_stat iterator; } memory; /** Disk related statistics. */ struct { /** Number of statements stored on disk. */ struct vy_disk_stmt_counter count; + /** Run iterator statistics. */ + struct vy_run_iterator_stat iterator; } disk; }; diff --git a/test/vinyl/bloom.result b/test/vinyl/bloom.result index 92401635a694b4b305268fb4f4ca58032bce9e3a..9d62b602559fbf5661afc5c6b7557855d45ae495 100644 --- a/test/vinyl/bloom.result +++ b/test/vinyl/bloom.result @@ -7,13 +7,13 @@ test_run = require('test_run').new() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i = s:create_index('test') +_ = s:create_index('pk') --- ... reflects = 0 --- ... -function cur_reflects() return box.info.vinyl().performance["iterator"].run.bloom_reflect_count end +function cur_reflects() return box.space.test.index.pk:info().disk.iterator.bloom.hit end --- ... function new_reflects() local o = reflects reflects = cur_reflects() return reflects - o end @@ -22,7 +22,7 @@ function new_reflects() local o = reflects reflects = cur_reflects() return refl seeks = 0 --- ... -function cur_seeks() return box.info.vinyl().performance["iterator"].run.lookup_count end +function cur_seeks() return box.space.test.index.pk:info().disk.iterator.lookup end --- ... function new_seeks() local o = seeks seeks = cur_seeks() return seeks - o end @@ -70,7 +70,7 @@ s = box.space.test reflects = 0 --- ... -function cur_reflects() return box.info.vinyl().performance["iterator"].run.bloom_reflect_count end +function cur_reflects() return box.space.test.index.pk:info().disk.iterator.bloom.hit end --- ... function new_reflects() local o = reflects reflects = cur_reflects() return reflects - o end @@ -79,7 +79,7 @@ function new_reflects() local o = reflects reflects = cur_reflects() return refl seeks = 0 --- ... -function cur_seeks() return box.info.vinyl().performance["iterator"].run.lookup_count end +function cur_seeks() return box.space.test.index.pk:info().disk.iterator.lookup end --- ... function new_seeks() local o = seeks seeks = cur_seeks() return seeks - o end diff --git a/test/vinyl/bloom.test.lua b/test/vinyl/bloom.test.lua index c6d40a6c75e6e8d6358e83c5fc4b90ab2ea07744..2f7b68f959501cf6bd5786709a0303d3e5183cb7 100644 --- a/test/vinyl/bloom.test.lua +++ b/test/vinyl/bloom.test.lua @@ -3,13 +3,13 @@ test_run = require('test_run').new() s = box.schema.space.create('test', {engine = 'vinyl'}) -i = s:create_index('test') +_ = s:create_index('pk') reflects = 0 -function cur_reflects() return box.info.vinyl().performance["iterator"].run.bloom_reflect_count end +function cur_reflects() return box.space.test.index.pk:info().disk.iterator.bloom.hit end function new_reflects() local o = reflects reflects = cur_reflects() return reflects - o end seeks = 0 -function cur_seeks() return box.info.vinyl().performance["iterator"].run.lookup_count end +function cur_seeks() return box.space.test.index.pk:info().disk.iterator.lookup end function new_seeks() local o = seeks seeks = cur_seeks() return seeks - o end for i = 1,1000 do s:replace{i} end @@ -28,11 +28,12 @@ new_seeks() < 20 test_run:cmd('restart server default') s = box.space.test + reflects = 0 -function cur_reflects() return box.info.vinyl().performance["iterator"].run.bloom_reflect_count end +function cur_reflects() return box.space.test.index.pk:info().disk.iterator.bloom.hit end function new_reflects() local o = reflects reflects = cur_reflects() return reflects - o end seeks = 0 -function cur_seeks() return box.info.vinyl().performance["iterator"].run.lookup_count end +function cur_seeks() return box.space.test.index.pk:info().disk.iterator.lookup end function new_seeks() local o = seeks seeks = cur_seeks() return seeks - o end _ = new_reflects() diff --git a/test/vinyl/cache.result b/test/vinyl/cache.result index ab78f31d9b9ebce1432c1354fd72447735393a31..8033149e3ee783ca2c169f032ed9fae008ac531d 100644 --- a/test/vinyl/cache.result +++ b/test/vinyl/cache.result @@ -8,25 +8,16 @@ test_run:cmd("setopt delimiter ';'") --- - true ... -stat = { - run_step_count = 0, - run_lookup_count = 0, - mem_step_count = 0, -} +stat = nil function stat_changed() local old_stat = stat - local new_stat = box.info.vinyl().performance["iterator"] - stat = { - run_step_count=new_stat.run.step_count, - run_lookup_count=new_stat.run.lookup_count, - mem_step_count=new_stat.mem.step_count, - } - for k,v in pairs(stat) do - if old_stat[k] ~= v then - return true - end - end - return false + local new_stat = box.space.test.index.pk:info() + stat = new_stat + return (old_stat == nil or + old_stat.memory.iterator.lookup ~= new_stat.memory.iterator.lookup or + old_stat.memory.iterator.get.rows ~= new_stat.memory.iterator.get.rows or + old_stat.disk.iterator.lookup ~= new_stat.disk.iterator.lookup or + old_stat.disk.iterator.get.rows ~= new_stat.disk.iterator.get.rows) end; --- ... @@ -37,7 +28,7 @@ test_run:cmd("setopt delimiter ''"); s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i = s:create_index('test') +pk = s:create_index('pk') --- ... str = string.rep('!', 100) @@ -74,7 +65,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) --- ... str = '' @@ -124,7 +115,7 @@ box.snapshot() --- - ok ... -a = stat_changed() -- init +_ = stat_changed() -- init --- ... box.begin() @@ -223,7 +214,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) --- ... str = '' @@ -273,7 +264,7 @@ box.snapshot() --- - ok ... -a = stat_changed() -- init +_ = stat_changed() -- init --- ... box.begin() @@ -341,7 +332,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) --- ... str = '' @@ -412,7 +403,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) --- ... s:replace{1, 1, 1} @@ -438,11 +429,11 @@ s:replace{5, 5, 5} box.begin() --- ... -i1:min() +pk:min() --- - [1, 1, 1] ... -i1:max() +pk:max() --- - [5, 5, 5] ... @@ -457,11 +448,11 @@ s:replace{6, 6, 6} --- - [6, 6, 6] ... -i1:min() +pk:min() --- - [0, 0, 0] ... -i1:max() +pk:max() --- - [6, 6, 6] ... @@ -472,7 +463,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i = s:create_index('test') +pk = s:create_index('pk') --- ... str = string.rep('!', 100) @@ -507,7 +498,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) --- ... str = '' @@ -557,7 +548,7 @@ box.snapshot() --- - ok ... -a = stat_changed() -- init +_ = stat_changed() -- init --- ... s:get{1, 2} @@ -638,7 +629,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) --- ... str = '' @@ -688,7 +679,7 @@ box.snapshot() --- - ok ... -a = stat_changed() -- init +_ = stat_changed() -- init --- ... s:select{} @@ -750,7 +741,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) --- ... str = '' @@ -815,7 +806,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) --- ... -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) --- ... s:replace{1, 1, 1} @@ -838,11 +829,11 @@ s:replace{5, 5, 5} --- - [5, 5, 5] ... -i1:min() +pk:min() --- - [1, 1, 1] ... -i1:max() +pk:max() --- - [5, 5, 5] ... @@ -854,11 +845,11 @@ s:replace{6, 6, 6} --- - [6, 6, 6] ... -i1:min() +pk:min() --- - [0, 0, 0] ... -i1:max() +pk:max() --- - [6, 6, 6] ... @@ -869,7 +860,7 @@ s:drop() local_space = box.schema.space.create('test', {engine='vinyl'}) --- ... -pk = local_space:create_index('primary') +pk = local_space:create_index('pk') --- ... local_space:replace({1, 1}) diff --git a/test/vinyl/cache.test.lua b/test/vinyl/cache.test.lua index 4e7fe46197c67b9997a2aac175f1adcaa6689ae2..bb06dbea746a8630968b6772e7c50c72ff6b4d37 100644 --- a/test/vinyl/cache.test.lua +++ b/test/vinyl/cache.test.lua @@ -3,30 +3,21 @@ test_run = require('test_run').new() test_run:cmd("setopt delimiter ';'") -stat = { - run_step_count = 0, - run_lookup_count = 0, - mem_step_count = 0, -} +stat = nil function stat_changed() local old_stat = stat - local new_stat = box.info.vinyl().performance["iterator"] - stat = { - run_step_count=new_stat.run.step_count, - run_lookup_count=new_stat.run.lookup_count, - mem_step_count=new_stat.mem.step_count, - } - for k,v in pairs(stat) do - if old_stat[k] ~= v then - return true - end - end - return false + local new_stat = box.space.test.index.pk:info() + stat = new_stat + return (old_stat == nil or + old_stat.memory.iterator.lookup ~= new_stat.memory.iterator.lookup or + old_stat.memory.iterator.get.rows ~= new_stat.memory.iterator.get.rows or + old_stat.disk.iterator.lookup ~= new_stat.disk.iterator.lookup or + old_stat.disk.iterator.get.rows ~= new_stat.disk.iterator.get.rows) end; test_run:cmd("setopt delimiter ''"); s = box.schema.space.create('test', {engine = 'vinyl'}) -i = s:create_index('test') +pk = s:create_index('pk') str = string.rep('!', 100) @@ -47,7 +38,7 @@ t = s:replace{200, str} s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) str = '' @@ -63,7 +54,7 @@ s:replace{2, 4, 2, str} s:replace{3, 3, 4} box.snapshot() -a = stat_changed() -- init +_ = stat_changed() -- init box.begin() s:get{1, 2} @@ -92,7 +83,7 @@ stat_changed() -- cache hit, false s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) str = '' @@ -108,7 +99,7 @@ s:replace{2, 4, 2, str} s:replace{3, 3, 4} box.snapshot() -a = stat_changed() -- init +_ = stat_changed() -- init box.begin() s:select{} @@ -127,7 +118,7 @@ stat_changed() -- cache hit, false s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) str = '' @@ -153,7 +144,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) s:replace{1, 1, 1} s:replace{2, 2, 2} @@ -162,22 +153,22 @@ s:replace{4, 4, 4} s:replace{5, 5, 5} box.begin() -i1:min() -i1:max() +pk:min() +pk:max() box.commit() s:replace{0, 0, 0} s:replace{6, 6, 6} -i1:min() -i1:max() +pk:min() +pk:max() s:drop() -- Same test w/o begin/end s = box.schema.space.create('test', {engine = 'vinyl'}) -i = s:create_index('test') +pk = s:create_index('pk') str = string.rep('!', 100) @@ -197,7 +188,7 @@ t = s:replace{200, str} s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) str = '' @@ -213,7 +204,7 @@ s:replace{2, 4, 2, str} s:replace{3, 3, 4} box.snapshot() -a = stat_changed() -- init +_ = stat_changed() -- init s:get{1, 2} stat_changed() -- cache miss, true @@ -236,7 +227,7 @@ stat_changed() -- cache hit, false s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) str = '' @@ -252,7 +243,7 @@ s:replace{2, 4, 2, str} s:replace{3, 3, 4} box.snapshot() -a = stat_changed() -- init +_ = stat_changed() -- init s:select{} stat_changed() -- cache miss, true @@ -269,7 +260,7 @@ stat_changed() -- cache hit, false s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) str = '' @@ -293,7 +284,7 @@ s:drop() s = box.schema.space.create('test', {engine = 'vinyl'}) -i1 = s:create_index('test1', {parts = {1, 'uint', 2, 'uint'}}) +pk = s:create_index('pk', {parts = {1, 'uint', 2, 'uint'}}) s:replace{1, 1, 1} s:replace{2, 2, 2} @@ -301,21 +292,21 @@ s:replace{3, 3, 3} s:replace{4, 4, 4} s:replace{5, 5, 5} -i1:min() -i1:max() +pk:min() +pk:max() s:replace{0, 0, 0} s:replace{6, 6, 6} -i1:min() -i1:max() +pk:min() +pk:max() s:drop() -- https://github.com/tarantool/tarantool/issues/2189 local_space = box.schema.space.create('test', {engine='vinyl'}) -pk = local_space:create_index('primary') +pk = local_space:create_index('pk') local_space:replace({1, 1}) local_space:replace({2, 2}) local_space:select{}