diff --git a/src/box/vinyl.c b/src/box/vinyl.c index a89a1c27ed2092de6f75a20ce91407032bf70ad3..d83a81c3ff2a0e3e2c63c8fb98c0f4ae95bec1c0 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -250,6 +250,7 @@ vy_info_append_scheduler(struct vy_env *env, struct info_handler *h) struct vy_scheduler_stat *stat = &env->scheduler.stat; info_table_begin(h, "scheduler"); + info_append_int(h, "dump_count", stat->dump_count); info_append_int(h, "dump_input", stat->dump_input); info_append_int(h, "dump_output", stat->dump_output); info_append_int(h, "compaction_input", stat->compaction_input); diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c index f65f4b1400dbe06f08404ab1077cf52376a3d968..140d289f8b00da7842205adefece5fdb3063d750 100644 --- a/src/box/vy_scheduler.c +++ b/src/box/vy_scheduler.c @@ -504,6 +504,7 @@ void vy_scheduler_reset_stat(struct vy_scheduler *scheduler) { struct vy_scheduler_stat *stat = &scheduler->stat; + stat->dump_count = 0; stat->dump_input = 0; stat->dump_output = 0; stat->compaction_input = 0; @@ -668,6 +669,7 @@ vy_scheduler_complete_dump(struct vy_scheduler *scheduler) double dump_duration = now - scheduler->dump_start; scheduler->dump_start = now; scheduler->dump_generation = min_generation; + scheduler->stat.dump_count++; scheduler->dump_complete_cb(scheduler, min_generation - 1, dump_duration); fiber_cond_signal(&scheduler->dump_cond); diff --git a/src/box/vy_stat.h b/src/box/vy_stat.h index 62ef2b757e02b86623bb373c46463a68a71c9c5e..37894429cc4bbc2f34845a8ab27c7e85ed158e9c 100644 --- a/src/box/vy_stat.h +++ b/src/box/vy_stat.h @@ -212,6 +212,8 @@ struct vy_tx_stat { * disk compression. */ struct vy_scheduler_stat { + /** Number of completed memory dumps. */ + int32_t dump_count; /** Number of bytes read by dump tasks. */ int64_t dump_input; /** Number of bytes written by dump tasks. */ diff --git a/test/vinyl/stat.result b/test/vinyl/stat.result index 16f019457fb0cb7100cbbeb0300066c79f3d1b23..e8780e5bdca9e13cab5cd4eab99ba8c5370b611d 100644 --- a/test/vinyl/stat.result +++ b/test/vinyl/stat.result @@ -242,8 +242,9 @@ gstat() data: 0 index: 0 scheduler: - compaction_output: 0 compaction_queue: 0 + dump_count: 0 + compaction_output: 0 dump_output: 0 dump_input: 0 compaction_input: 0 @@ -1091,8 +1092,9 @@ gstat() data: 104300 index: 1190 scheduler: - compaction_output: 0 compaction_queue: 0 + dump_count: 0 + compaction_output: 0 dump_output: 0 dump_input: 0 compaction_input: 0 @@ -1100,6 +1102,79 @@ gstat() s:drop() --- ... +-- sched stats +s = box.schema.space.create('test', {engine = 'vinyl'}) +--- +... +i1 = s:create_index('i1', {parts = {1, 'unsigned'}}) +--- +... +i2 = s:create_index('i2', {parts = {2, 'unsigned'}}) +--- +... +for i = 1, 100 do s:replace{i, i, string.rep('x', 1000)} end +--- +... +st = gstat() +--- +... +box.snapshot() +--- +- ok +... +stat_diff(gstat(), st, 'scheduler') +--- +- dump_count: 1 + dump_input: 208400 + dump_output: 103592 +... +for i = 1, 100, 10 do s:replace{i, i, string.rep('y', 1000)} end +--- +... +st = gstat() +--- +... +box.snapshot() +--- +- ok +... +stat_diff(gstat(), st, 'scheduler') +--- +- dump_count: 1 + dump_input: 21230 + dump_output: 10371 +... +st = gstat() +--- +... +i1:compact() +--- +... +while i1:stat().disk.compaction.count == 0 do fiber.sleep(0.01) end +--- +... +stat_diff(gstat(), st, 'scheduler') +--- +- compaction_input: 112188 + compaction_output: 101984 +... +st = gstat() +--- +... +i2:compact() +--- +... +while i2:stat().disk.compaction.count == 0 do fiber.sleep(0.01) end +--- +... +stat_diff(gstat(), st, 'scheduler') +--- +- compaction_input: 1775 + compaction_output: 1608 +... +s:drop() +--- +... -- -- space.bsize, index.len, index.bsize -- diff --git a/test/vinyl/stat.test.lua b/test/vinyl/stat.test.lua index 6708fcb9ceeeaa7aa5c07b272db11ed6236c871d..f2acf3e8b887a8cc11355131cf5f5956ef9a30de 100644 --- a/test/vinyl/stat.test.lua +++ b/test/vinyl/stat.test.lua @@ -320,6 +320,33 @@ gstat() s:drop() +-- sched stats +s = box.schema.space.create('test', {engine = 'vinyl'}) +i1 = s:create_index('i1', {parts = {1, 'unsigned'}}) +i2 = s:create_index('i2', {parts = {2, 'unsigned'}}) + +for i = 1, 100 do s:replace{i, i, string.rep('x', 1000)} end +st = gstat() +box.snapshot() +stat_diff(gstat(), st, 'scheduler') + +for i = 1, 100, 10 do s:replace{i, i, string.rep('y', 1000)} end +st = gstat() +box.snapshot() +stat_diff(gstat(), st, 'scheduler') + +st = gstat() +i1:compact() +while i1:stat().disk.compaction.count == 0 do fiber.sleep(0.01) end +stat_diff(gstat(), st, 'scheduler') + +st = gstat() +i2:compact() +while i2:stat().disk.compaction.count == 0 do fiber.sleep(0.01) end +stat_diff(gstat(), st, 'scheduler') + +s:drop() + -- -- space.bsize, index.len, index.bsize --