]> granicus.if.org Git - gc/commitdiff
Dump the block information in CSV format
authorPaul Bone <paul@bone.id.au>
Fri, 10 Jun 2016 08:11:47 +0000 (11:11 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 10 Jun 2016 08:28:27 +0000 (11:28 +0300)
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

index 4f40cbb43fbebdadfe05a39f8bce5059154a66d0..849726e2441ebff9429536828f542345fce5e95a 100644 (file)
--- 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);