From edc6c7ec9904684fa5bd1dfa67045086a85d218f Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 10 Apr 2025 13:26:33 -0500 Subject: [PATCH] scripts: dbgbmap[d3].py: Reverted percentages to entire bmap So percentages now include unused blocks, instead of being derived from only blocks in use. This is a bit inconsistent with tracebd.py, where we show ops as percentages of all ops, but it's more useful: - mdir+btree+data gives you the total usage, which is useful if you want to know how full disk is. You can't get this info from in-use percentages. Note that total field is sticking around, so you can show the total usage directly if you provide your own title string: $ ./scripts/dbgbmap.py disk \ --title="bd %(block_size)sx%(block_count)s, %(total_percent)s" - You can derive the in-use percentages from total percentages if you need them: in-use-mdir = mdir/(mdir+btree+data). Maybe this should be added to the --title fields, but I can't think of a good name at the moment... Attempting to make tracebd.py consistent with dbgbmap.py doesn't really make sense either: Showing op percentages of total bmap will usually be an extremely small number. At least dbgbmap.py is consistent with tracebd.py's --wear percentage, which is out of all erase state in the bmap. --- scripts/dbgbmap.py | 14 ++++++++------ scripts/dbgbmapd3.py | 14 ++++++++------ scripts/tracebd.py | 34 +++++++++++++++------------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/scripts/dbgbmap.py b/scripts/dbgbmap.py index 3fb88119..b6bf7e4c 100755 --- a/scripts/dbgbmap.py +++ b/scripts/dbgbmap.py @@ -4724,15 +4724,17 @@ def main_(f, disk, mroots=None, *, lfs.cksum, '' if lfs.ckgcksum() else '?'), 'total': total_count, + 'total_percent': '%.1f%%' % ( + 100*total_count / max(len(bmap), 1)), 'mdir': mdir_count, 'mdir_percent': '%.1f%%' % ( - 100*(mdir_count / max(total_count, 1))), + 100*mdir_count / max(len(bmap), 1)), 'btree': btree_count, 'btree_percent': '%.1f%%' % ( - 100*(btree_count / max(total_count, 1))), + 100*btree_count / max(len(bmap), 1)), 'data': data_count, 'data_percent': '%.1f%%' % ( - 100*(data_count / max(total_count, 1))), + 100*data_count / max(len(bmap), 1)), })) elif title_littlefs: f.writeln('littlefs%s v%s.%s %sx%s %s w%s.%s, cksum %08x%s' % ( @@ -4749,9 +4751,9 @@ def main_(f, disk, mroots=None, *, f.writeln('bd %sx%s, %6s mdir, %6s btree, %6s data' % ( lfs.block_size if lfs.block_size is not None else '?', lfs.block_count if lfs.block_count is not None else '?', - '%.1f%%' % (100*(mdir_count / max(total_count, 1))), - '%.1f%%' % (100*(btree_count / max(total_count, 1))), - '%.1f%%' % (100*(data_count / max(total_count, 1))))) + '%.1f%%' % (100*mdir_count / max(len(bmap), 1)), + '%.1f%%' % (100*btree_count / max(len(bmap), 1)), + '%.1f%%' % (100*data_count / max(len(bmap), 1)))) # draw canvas for row in range(canvas.height//canvas.yscale): diff --git a/scripts/dbgbmapd3.py b/scripts/dbgbmapd3.py index 242c1798..82b50422 100755 --- a/scripts/dbgbmapd3.py +++ b/scripts/dbgbmapd3.py @@ -5007,15 +5007,17 @@ def main(disk, output, mroots=None, *, lfs.cksum, '' if lfs.ckgcksum() else '?'), 'total': total_count, + 'total_percent': '%.1f%%' % ( + 100*total_count / max(len(bmap), 1)), 'mdir': mdir_count, 'mdir_percent': '%.1f%%' % ( - 100*(mdir_count / max(total_count, 1))), + 100*mdir_count / max(len(bmap), 1)), 'btree': btree_count, 'btree_percent': '%.1f%%' % ( - 100*(btree_count / max(total_count, 1))), + 100*btree_count / max(len(bmap), 1)), 'data': data_count, 'data_percent': '%.1f%%' % ( - 100*(data_count / max(total_count, 1))), + 100*data_count / max(len(bmap), 1)), })) elif not title_usage: f.write('littlefs%s v%s.%s %sx%s %s w%s.%s, cksum %08x%s' % ( @@ -5032,9 +5034,9 @@ def main(disk, output, mroots=None, *, f.writeln('bd %sx%s, %s mdir, %s btree, %s data' % ( lfs.block_size if lfs.block_size is not None else '?', lfs.block_count if lfs.block_count is not None else '?', - '%.1f%%' % (100*(mdir_count / max(total_count, 1))), - '%.1f%%' % (100*(btree_count / max(total_count, 1))), - '%.1f%%' % (100*(data_count / max(total_count, 1))))) + '%.1f%%' % (100*mdir_count / max(len(bmap), 1)), + '%.1f%%' % (100*btree_count / max(len(bmap), 1)), + '%.1f%%' % (100*data_count / max(len(bmap), 1)))) f.write('') if not no_mode and not no_javascript: f.write('