[PATCH 1/2] vinyl: report size of memory used for indexing data in index.info
Vladimir Davydov
vdavydov.dev at gmail.com
Sun Feb 4 18:57:43 MSK 2018
This patch adds the following statistics to index.info:
- memory.index_size - size of memory tree extents
- cache.index_size - size of cache tree extents
- disk.index_size - size of page index
- disk.bloom_size - size of bloom filters
---
src/box/vinyl.c | 5 +++++
src/box/vy_index.c | 16 ++++++++++++++++
src/box/vy_index.h | 8 ++++++++
test/vinyl/info.result | 25 +++++++++++++++++--------
4 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index b2331081..65bcbc02 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -429,6 +429,7 @@ vinyl_index_info(struct index *base, struct info_handler *h)
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_append_int(h, "index_size", vy_index_mem_tree_size(index));
info_table_end(h);
info_table_begin(h, "disk");
@@ -444,6 +445,8 @@ vinyl_index_info(struct index *base, struct info_handler *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_append_int(h, "index_size", index->page_index_size);
+ info_append_int(h, "bloom_size", index->bloom_size);
info_table_end(h);
info_table_begin(h, "cache");
@@ -453,6 +456,8 @@ vinyl_index_info(struct index *base, struct info_handler *h)
vy_info_append_stmt_counter(h, "put", &cache_stat->put);
vy_info_append_stmt_counter(h, "invalidate", &cache_stat->invalidate);
vy_info_append_stmt_counter(h, "evict", &cache_stat->evict);
+ info_append_int(h, "index_size",
+ vy_cache_tree_mem_used(&index->cache.cache_tree));
info_table_end(h);
info_table_begin(h, "txw");
diff --git a/src/box/vy_index.c b/src/box/vy_index.c
index 93bf71a8..0596c4ed 100644
--- a/src/box/vy_index.c
+++ b/src/box/vy_index.c
@@ -120,6 +120,16 @@ vy_index_name(struct vy_index *index)
return buf;
}
+size_t
+vy_index_mem_tree_size(struct vy_index *index)
+{
+ struct vy_mem *mem;
+ size_t size = index->mem->tree_extent_size;
+ rlist_foreach_entry(mem, &index->sealed, in_sealed)
+ size += mem->tree_extent_size;
+ return size;
+}
+
struct vy_index *
vy_index_new(struct vy_index_env *index_env, struct vy_cache_env *cache_env,
struct vy_mem_env *mem_env, struct index_def *index_def,
@@ -692,6 +702,9 @@ vy_index_add_run(struct vy_index *index, struct vy_run *run)
index->run_count++;
vy_disk_stmt_counter_add(&index->stat.disk.count, &run->count);
+ index->bloom_size += bloom_store_size(&run->info.bloom);
+ index->page_index_size += run->page_index_size;
+
index->env->bloom_size += bloom_store_size(&run->info.bloom);
index->env->page_index_size += run->page_index_size;
}
@@ -705,6 +718,9 @@ vy_index_remove_run(struct vy_index *index, struct vy_run *run)
index->run_count--;
vy_disk_stmt_counter_sub(&index->stat.disk.count, &run->count);
+ index->bloom_size -= bloom_store_size(&run->info.bloom);
+ index->page_index_size -= run->page_index_size;
+
index->env->bloom_size -= bloom_store_size(&run->info.bloom);
index->env->page_index_size -= run->page_index_size;
}
diff --git a/src/box/vy_index.h b/src/box/vy_index.h
index b31d2161..47fa335f 100644
--- a/src/box/vy_index.h
+++ b/src/box/vy_index.h
@@ -227,6 +227,10 @@ struct vy_index {
* have a particular number of runs.
*/
struct histogram *run_hist;
+ /** Size of memory used for bloom filters. */
+ size_t bloom_size;
+ /** Size of memory used for page index. */
+ size_t page_index_size;
/**
* Incremented for each change of the mem list,
* to invalidate iterators.
@@ -293,6 +297,10 @@ vy_index_validate_formats(const struct vy_index *index);
const char *
vy_index_name(struct vy_index *index);
+/** Return sum size of memory tree extents. */
+size_t
+vy_index_mem_tree_size(struct vy_index *index);
+
/** Allocate a new index object. */
struct vy_index *
vy_index_new(struct vy_index_env *index_env, struct vy_cache_env *cache_env,
diff --git a/test/vinyl/info.result b/test/vinyl/info.result
index c95f709b..2724cc3d 100644
--- a/test/vinyl/info.result
+++ b/test/vinyl/info.result
@@ -133,6 +133,7 @@ istat()
invalidate:
rows: 0
bytes: 0
+ index_size: 0
rows: 0
evict:
rows: 0
@@ -150,6 +151,9 @@ istat()
rows: 0
bytes: 0
disk:
+ index_size: 0
+ rows: 0
+ bytes: 0
dump:
in:
rows: 0
@@ -166,7 +170,6 @@ istat()
out:
rows: 0
bytes: 0
- rows: 0
iterator:
read:
bytes_compressed: 0
@@ -182,7 +185,7 @@ istat()
bytes: 0
pages: 0
bytes_compressed: 0
- bytes: 0
+ bloom_size: 0
txw:
bytes: 0
rows: 0
@@ -194,6 +197,7 @@ istat()
run_histogram: '[0]:1'
memory:
bytes: 0
+ index_size: 0
rows: 0
iterator:
lookup: 0
@@ -260,10 +264,12 @@ stat_diff(istat(), st)
out:
rows: 25
bytes: 26049
+ index_size: 294
rows: 25
+ bloom_size: 4096
pages: 7
- bytes_compressed: <bytes_compressed>
bytes: 26049
+ bytes_compressed: <bytes_compressed>
bytes: 26049
put:
rows: 25
@@ -294,6 +300,11 @@ stat_diff(istat(), st)
out:
rows: 50
bytes: 52091
+ index_size: 252
+ rows: 25
+ bytes_compressed: <bytes_compressed>
+ pages: 6
+ bytes: 26042
compact:
in:
rows: 75
@@ -302,10 +313,6 @@ stat_diff(istat(), st)
out:
rows: 50
bytes: 52091
- rows: 25
- pages: 6
- bytes_compressed: <bytes_compressed>
- bytes: 26042
put:
rows: 50
bytes: 53050
@@ -323,9 +330,10 @@ s:get(1) ~= nil
stat_diff(istat(), st)
---
- cache:
+ index_size: 49152
+ rows: 1
bytes: 1061
lookup: 1
- rows: 1
put:
rows: 1
bytes: 1061
@@ -388,6 +396,7 @@ stat_diff(istat(), st)
bytes: -1061
rows: 1
memory:
+ index_size: 49152
bytes: 1061
rows: 1
put:
--
2.11.0
More information about the Tarantool-patches
mailing list