From d55c08ac9c0a71d51287e25982001104ae83b93d Mon Sep 17 00:00:00 2001 From: Paul Bone Date: Fri, 10 Jun 2016 11:11:47 +0300 Subject: [PATCH] Dump the block information in CSV format This makes it easy to copy this information into a new file and process it with tools that understand CSV, e.g. to create histograms of block utilization. * reclaim.c (GC_print_block_descr): add n_objs local variable; separate printed values with a comma; print also size of block in object units; refactor code for computing total_bytes field. * reclaim.c (GC_print_block_list): Separate columns in printed table header with a comma; append "#objs" column to the table. --- reclaim.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/reclaim.c b/reclaim.c index 4f40cbb4..849726e2 100644 --- a/reclaim.c +++ b/reclaim.c @@ -535,19 +535,19 @@ STATIC void GC_print_block_descr(struct hblk *h, size_t bytes = hhdr -> hb_sz; struct Print_stats *ps; unsigned n_marks = GC_n_set_marks(hhdr); + unsigned n_objs = HBLK_OBJS((unsigned)bytes); + if (0 == n_objs) n_objs = 1; if (hhdr -> hb_n_marks != n_marks) { - GC_printf("(%u:%u,%u!=%u)\n", hhdr->hb_obj_kind, (unsigned)bytes, - (unsigned)hhdr->hb_n_marks, n_marks); + GC_printf("%u,%u,%u!=%u,%u\n", hhdr->hb_obj_kind, (unsigned)bytes, + (unsigned)hhdr->hb_n_marks, n_marks, n_objs); } else { - GC_printf("(%u:%u,%u)\n", hhdr->hb_obj_kind, - (unsigned)bytes, n_marks); + GC_printf("%u,%u,%u,%u\n", hhdr->hb_obj_kind, (unsigned)bytes, + n_marks, n_objs); } - bytes += HBLKSIZE-1; - bytes &= ~(HBLKSIZE-1); ps = (struct Print_stats *)raw_ps; - ps->total_bytes += bytes; + ps->total_bytes += (bytes + (HBLKSIZE-1)) & ~(HBLKSIZE-1); /* round up */ ps->number_of_blocks++; } @@ -555,7 +555,8 @@ void GC_print_block_list(void) { struct Print_stats pstats; - GC_printf("(kind(0=ptrfree,1=normal,2=unc.):size_in_bytes, #_marks_set)\n"); + GC_printf("kind(0=ptrfree,1=normal,2=unc.)," + "size_in_bytes,#_marks_set,#objs\n"); pstats.number_of_blocks = 0; pstats.total_bytes = 0; GC_apply_to_all_blocks(GC_print_block_descr, (word)&pstats); -- 2.40.0