[PATCH 08/12] vinyl: add dump count to global scheduler statistics
Vladimir Davydov
vdavydov.dev at gmail.com
Tue Jan 15 17:17:17 MSK 2019
This patch adds scheduler.dump_count to box.stat.vinyl(), which shows
the number of memory level dumps that have happened since the instance
startup or box.stat.reset(). It's useful for estimating an average size
of a single memory dump, which in turn can be used for calculating LSM
tree fanout.
---
src/box/vinyl.c | 1 +
src/box/vy_scheduler.c | 2 ++
src/box/vy_stat.h | 2 ++
test/vinyl/stat.result | 79 ++++++++++++++++++++++++++++++++++++++++++++++--
test/vinyl/stat.test.lua | 27 +++++++++++++++++
5 files changed, 109 insertions(+), 2 deletions(-)
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index b30e69a1..e3478679 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 2d4f6bed..d06da484 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;
@@ -696,6 +697,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 195b09a4..b976db47 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 16f01945..e8780e5b 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 6708fcb9..f2acf3e8 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
--
--
2.11.0
More information about the Tarantool-patches
mailing list