From 03f3ae3e31d1b9e27830f29b388b2f3beb47aa06 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 14 Feb 2016 13:38:27 +0000 Subject: [PATCH] Print more info about radix tries --- src/libutil/map.c | 4 ++-- src/libutil/radix.c | 10 ++++++++++ src/libutil/radix.h | 7 +++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libutil/map.c b/src/libutil/map.c index ea5f3f210..7d21e2f26 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -957,7 +957,7 @@ rspamd_radix_fin (rspamd_mempool_t * pool, struct map_cb_data *data) radix_destroy_compressed (data->prev_data); } if (data->cur_data) { - msg_info_pool ("read radix trie of %z elements", radix_get_size - (data->cur_data)); + msg_info_pool ("read radix trie of %z elements: %s", + radix_get_size (data->cur_data), radix_get_info (data->cur_data)); } } diff --git a/src/libutil/radix.c b/src/libutil/radix.c index a8bf5e3d3..7dc0b8237 100644 --- a/src/libutil/radix.c +++ b/src/libutil/radix.c @@ -242,3 +242,13 @@ radix_get_pool (radix_compressed_t *tree) return NULL; } + +const gchar * +radix_get_info (radix_compressed_t *tree) +{ + if (tree == NULL) { + return NULL; + } + + return btrie_stats (tree->tree); +} diff --git a/src/libutil/radix.h b/src/libutil/radix.h index b2c4ed44f..41309fe72 100644 --- a/src/libutil/radix.h +++ b/src/libutil/radix.h @@ -95,6 +95,13 @@ gboolean radix_add_generic_iplist (const gchar *ip_list, */ gsize radix_get_size (radix_compressed_t *tree); +/** + * Return string that describes this radix tree (memory, nodes, compression etc) + * @param tree + * @return constant string + */ +const gchar * radix_get_info (radix_compressed_t *tree); + /** * Returns memory pool associated with the radix tree */ -- 2.39.5