From 7ee65c6b22c442048fb7c2b59cab80eca3bb53a3 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 27 Jul 2020 15:39:19 +0200 Subject: [PATCH] btrfs-progs: tree-stats: print average fanout for each level Calculate average fanout between levels: Levels: 4 Total nodes: 289048 On level 0: 288054 On level 1: 989 (avg fanout 291) On level 2: 4 (avg fanout 247) On level 3: 1 (avg fanout 4) Signed-off-by: David Sterba --- cmds/inspect-tree-stats.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmds/inspect-tree-stats.c b/cmds/inspect-tree-stats.c index cbdf704e..e807eaa2 100644 --- a/cmds/inspect-tree-stats.c +++ b/cmds/inspect-tree-stats.c @@ -407,8 +407,17 @@ out_print: } printf("\tLevels: %d\n", level + 1); printf("\tTotal nodes: %llu\n", stat.total_nodes); - for (i = 0; i < level + 1; i++) - printf("\t\tOn level %d: %llu\n", i, stat.node_counts[i]); + for (i = 0; i < level + 1; i++) { + printf("\t\tOn level %d: %8llu", i, stat.node_counts[i]); + if (i > 0) { + u64 fanout; + + fanout = stat.node_counts[i - 1]; + fanout /= stat.node_counts[i]; + printf(" (avg fanout %llu)", fanout); + } + printf("\n"); + } out: while ((n = rb_first(&stat.seek_root)) != NULL) { struct seek *seek = rb_entry(n, struct seek, n);