Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[sgen] Dump Mark&Sweep heap occupancy.

For each block size dump the occupancy to the heap-dump
file.
  • Loading branch information...
commit 7660facddecde450d0c7db010700b83ddea5f57b 1 parent 73f1564
@schani schani authored
Showing with 32 additions and 0 deletions.
  1. +24 −0 mono/metadata/sgen-marksweep.c
  2. +8 −0 scripts/mono-heapviz
View
24 mono/metadata/sgen-marksweep.c
@@ -703,6 +703,30 @@ static void
major_dump_heap (FILE *heap_dump_file)
{
MSBlockInfo *block;
+ int *slots_available = alloca (sizeof (int) * num_block_obj_sizes);
+ int *slots_used = alloca (sizeof (int) * num_block_obj_sizes);
+ int i;
+
+ for (i = 0; i < num_block_obj_sizes; ++i)
+ slots_available [i] = slots_used [i] = 0;
+
+ FOREACH_BLOCK (block) {
+ int index = ms_find_block_obj_size_index (block->obj_size);
+ int count = MS_BLOCK_FREE / block->obj_size;
+
+ slots_available [index] += count;
+ for (i = 0; i < count; ++i) {
+ if (MS_OBJ_ALLOCED (MS_BLOCK_OBJ (block, i), block))
+ ++slots_used [index];
+ }
+ } END_FOREACH_BLOCK;
+
+ fprintf (heap_dump_file, "<occupancies>\n");
+ for (i = 0; i < num_block_obj_sizes; ++i) {
+ fprintf (heap_dump_file, "<occupancy size=\"%d\" available=\"%d\" used=\"%d\" />\n",
+ block_obj_sizes [i], slots_available [i], slots_used [i]);
+ }
+ fprintf (heap_dump_file, "</occupancies>\n");
FOREACH_BLOCK (block) {
int count = MS_BLOCK_FREE / block->obj_size;
View
8 scripts/mono-heapviz
@@ -156,6 +156,7 @@ class DocHandler (ContentHandler):
self.usage = {}
self.los_usage = {}
self.pinned_usage = {}
+ self.occupancies = {}
self.in_los = False
self.in_pinned = False
self.heap_used = 0
@@ -169,6 +170,13 @@ class DocHandler (ContentHandler):
kind = attrs.get('type', None)
bytes = int(attrs.get('bytes', None))
print ('Pinned from %s: %d kB<br>' % (kind, bytes / 1024), file = self.collection_file)
+ elif name == 'occupancy':
+ size = int (attrs.get ('size', None))
+ available = int (attrs.get ('available', None))
+ used = int (attrs.get ('used', None))
+ unused = available - used
+
+ print ('Occupancy of %d byte slots: %d / %d (%d kB / %d%% wasted)<br>' % (size, used, available, unused * size / 1024, unused * 100 / available), file = self.collection_file)
elif name == 'section':
kind = attrs.get('type', None)
size = int(attrs.get('size', None))
Please sign in to comment.
Something went wrong with that request. Please try again.