diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 17f0c6af1afeed3b4f3106ffc7cf7ac3d1f7516d..8d6f30519d3ec3f8a11b84860707908e7864f529 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -3108,6 +3108,7 @@ vy_task_dump_complete(struct vy_task *task) * Account the new run. */ vy_index_add_run(index, new_run); + vy_stmt_counter_add_disk(&index->stat.disk.dump.out, &new_run->count); /* Drop the reference held by the task. */ vy_run_unref(new_run); @@ -3149,12 +3150,14 @@ vy_task_dump_complete(struct vy_task *task) continue; rlist_del_entry(mem, in_sealed); vy_stmt_counter_sub(&index->stat.memory.count, &mem->count); + vy_stmt_counter_add(&index->stat.disk.dump.in, &mem->count); vy_scheduler_remove_mem(scheduler, mem); vy_mem_delete(mem); } index->version++; index->dump_lsn = dump_lsn; index->generation = task->generation; + index->stat.disk.dump.count++; /* The iterator has been cleaned up in a worker thread. */ task->wi->iface->close(task->wi); @@ -3425,6 +3428,8 @@ vy_task_compact_complete(struct vy_task *task) */ if (new_slice != NULL) { vy_index_add_run(index, new_run); + vy_stmt_counter_add_disk(&index->stat.disk.compact.out, + &new_run->count); /* Drop the reference held by the task. */ vy_run_unref(new_run); } else @@ -3446,6 +3451,8 @@ vy_task_compact_complete(struct vy_task *task) next_slice = rlist_next_entry(slice, in_range); vy_range_remove_slice(range, slice); rlist_add_entry(&compacted_slices, slice, in_range); + vy_stmt_counter_add_disk(&index->stat.disk.compact.in, + &slice->count); if (slice == last_slice) break; } @@ -3453,6 +3460,7 @@ vy_task_compact_complete(struct vy_task *task) range->version++; vy_index_acct_range(index, range); vy_range_update_compact_priority(range); + index->stat.disk.compact.count++; /* * Unaccount unused runs and delete compacted slices. @@ -4524,6 +4532,17 @@ vy_info_append_disk_stmt_counter(struct info_handler *h, const char *name, info_table_end(h); } +static void +vy_info_append_compact_stat(struct info_handler *h, const char *name, + const struct vy_compact_stat *stat) +{ + info_table_begin(h, name); + info_append_int(h, "count", stat->count); + vy_info_append_stmt_counter(h, "in", &stat->in); + vy_info_append_stmt_counter(h, "out", &stat->out); + info_table_end(h); +} + void vy_index_info(struct vy_index *index, struct info_handler *h) { @@ -4532,10 +4551,9 @@ vy_index_info(struct vy_index *index, struct info_handler *h) 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); + struct vy_stmt_counter count = stat->memory.count; + vy_stmt_counter_add_disk(&count, &stat->disk.count); + vy_info_append_stmt_counter(h, NULL, &count); info_table_begin(h, "memory"); vy_info_append_stmt_counter(h, NULL, &stat->memory.count); @@ -4556,6 +4574,8 @@ vy_index_info(struct vy_index *index, struct info_handler *h) info_append_int(h, "miss", stat->disk.iterator.bloom_miss); info_table_end(h); info_table_end(h); + vy_info_append_compact_stat(h, "dump", &stat->disk.dump); + vy_info_append_compact_stat(h, "compact", &stat->disk.compact); info_table_end(h); info_append_int(h, "range_count", index->range_count); diff --git a/src/box/vy_stat.h b/src/box/vy_stat.h index 91e8b8a6bf9eea5e81333fdc25b2191242b614b3..23493ea322f93803954b5c6ef2d1f6496f270888 100644 --- a/src/box/vy_stat.h +++ b/src/box/vy_stat.h @@ -90,6 +90,15 @@ struct vy_run_iterator_stat { struct vy_disk_stmt_counter read; }; +/** Dump/compaction statistics. */ +struct vy_compact_stat { + int32_t count; + /** Number of input statements. */ + struct vy_stmt_counter in; + /** Number of output statements. */ + struct vy_stmt_counter out; +}; + /** Vinyl index statistics. */ struct vy_index_stat { /** Memory related statistics. */ @@ -105,6 +114,10 @@ struct vy_index_stat { struct vy_disk_stmt_counter count; /** Run iterator statistics. */ struct vy_run_iterator_stat iterator; + /** Dump statistics. */ + struct vy_compact_stat dump; + /** Compaction statistics. */ + struct vy_compact_stat compact; } disk; }; @@ -124,6 +137,14 @@ vy_stmt_counter_sub(struct vy_stmt_counter *c1, c1->bytes -= c2->bytes; } +static inline void +vy_stmt_counter_add_disk(struct vy_stmt_counter *c1, + const struct vy_disk_stmt_counter *c2) +{ + c1->rows += c2->rows; + c1->bytes += c2->bytes; +} + static inline void vy_disk_stmt_counter_add(struct vy_disk_stmt_counter *c1, const struct vy_disk_stmt_counter *c2)