summaryrefslogtreecommitdiffstats
path: root/Objects/obmalloc.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2021-04-01 03:46:31 (GMT)
committerGitHub <noreply@github.com>2021-04-01 03:46:31 (GMT)
commit078a3433ebe4c211cd93c84cd9c2148c3aa23238 (patch)
tree03b6a34e55d7b41a667edf406161e8e06f684d9e /Objects/obmalloc.c
parent58cffba1874f0e9a9731b25a3e11a011bfbbf95f (diff)
downloadcpython-078a3433ebe4c211cd93c84cd9c2148c3aa23238.zip
cpython-078a3433ebe4c211cd93c84cd9c2148c3aa23238.tar.gz
cpython-078a3433ebe4c211cd93c84cd9c2148c3aa23238.tar.bz2
When printing stats, move radix tree info to its own section. (GH-25125)
When printing stats, move radix tree info to its own section. Restore that the breakdown of bytes in arenas exactly accounts for the total of arena bytes allocated. Add an assert so that invariant doesn't break again.
Diffstat (limited to 'Objects/obmalloc.c')
-rw-r--r--Objects/obmalloc.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 76ff6f9..c1c1279 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -3027,12 +3027,6 @@ _PyObject_DebugMallocStats(FILE *out)
(void)printone(out, "# arenas reclaimed", ntimes_arena_allocated - narenas);
(void)printone(out, "# arenas highwater mark", narenas_highwater);
(void)printone(out, "# arenas allocated current", narenas);
-#ifdef USE_INTERIOR_NODES
- (void)printone(out, "# arena map mid nodes", arena_map_mid_count);
- (void)printone(out, "# arena map bot nodes", arena_map_bot_count);
- fputc('\n', out);
-#endif
-
PyOS_snprintf(buf, sizeof(buf),
"%zu arenas * %d bytes/arena",
@@ -3041,6 +3035,7 @@ _PyObject_DebugMallocStats(FILE *out)
fputc('\n', out);
+ /* Account for what all of those arena bytes are being used for. */
total = printone(out, "# bytes in allocated blocks", allocated_bytes);
total += printone(out, "# bytes in available blocks", available_bytes);
@@ -3051,16 +3046,26 @@ _PyObject_DebugMallocStats(FILE *out)
total += printone(out, "# bytes lost to pool headers", pool_header_bytes);
total += printone(out, "# bytes lost to quantization", quantization);
total += printone(out, "# bytes lost to arena alignment", arena_alignment);
-#ifdef WITH_PYMALLOC_RADIX_TREE
- total += printone(out, "# bytes lost to arena map root", sizeof(arena_map_root));
+ (void)printone(out, "Total", total);
+ assert(narenas * ARENA_SIZE == total);
+
+#if WITH_PYMALLOC_RADIX_TREE
+ fputs("\narena map counts\n", out);
+#ifdef USE_INTERIOR_NODES
+ (void)printone(out, "# arena map mid nodes", arena_map_mid_count);
+ (void)printone(out, "# arena map bot nodes", arena_map_bot_count);
+ fputc('\n', out);
#endif
+ total = printone(out, "# bytes lost to arena map root", sizeof(arena_map_root));
#ifdef USE_INTERIOR_NODES
total += printone(out, "# bytes lost to arena map mid",
sizeof(arena_map_mid_t) * arena_map_mid_count);
total += printone(out, "# bytes lost to arena map bot",
sizeof(arena_map_bot_t) * arena_map_bot_count);
-#endif
(void)printone(out, "Total", total);
+#endif
+#endif
+
return 1;
}