Revision: 54567
http://brlcad.svn.sourceforge.net/brlcad/?rev=54567&view=rev
Author: brlcad
Date: 2013-03-08 15:32:49 +0000 (Fri, 08 Mar 2013)
Log Message:
-----------
increase the range of supported allocations from 1-256 and 1MB-sized pages.
minor overhead to support an even bigger range, but pagesize should probably
not exceed 1MB. report additional stats on the number of hits (allocations in
range) and misses (out of range size).
Modified Paths:
--------------
brlcad/trunk/src/libbu/heap.c
Modified: brlcad/trunk/src/libbu/heap.c
===================================================================
--- brlcad/trunk/src/libbu/heap.c 2013-03-08 14:57:55 UTC (rev 54566)
+++ brlcad/trunk/src/libbu/heap.c 2013-03-08 15:32:49 UTC (rev 54567)
@@ -28,19 +28,22 @@
#include "bu.h"
-#define BINS 64
-#define PAGESIZE (BINS * 1024)
+#define BINS 256
+#define PAGESIZE (BINS * 4096)
/** heaps is an array of lists containing pages of memory binned per requested
allocation size */
-static char **heaps[BINS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+static char **heaps[BINS] = {0};
/** pages is an array of counts for how many heap pages have been allocated
per each heaps[] size */
-static size_t pages[BINS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+static size_t pages[BINS] = {0};
/** used is an array of lists to count how much memory has been used
(allocated) per page */
-static size_t *used[BINS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+static size_t *used[BINS] = {0};
-static size_t alloc[BINS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+/** keep track of our allocation counts for reporting stats */
+static size_t alloc[BINS] = {0};
+
+/** keep track of allocation sizes outside our supported range */
static size_t misses = 0;
@@ -50,6 +53,7 @@
size_t i, j;
size_t allocations = 0;
size_t total_pages = 0;
+ size_t total_alloc = 0;
bu_log("=======================\n"
"Memory Heap Information\n"
@@ -63,13 +67,15 @@
if (allocations > 0)
bu_log("%04ld [%02ld] => %ld\n", i, pages[i], allocations);
total_pages += pages[i];
+ total_alloc += allocations;
}
bu_log("-----------------------\n"
"size [pages] => allocs\n"
"Heap range: 1-%ld bytes\n"
"Page size: %ld bytes\n"
"Pages: %ld (%.2lfMB)\n"
- "=======================\n", BINS, PAGESIZE, total_pages,
(double)(total_pages * PAGESIZE) / (1024.0*1024.0));
+ "%ld hits, %ld misses\n"
+ "=======================\n", BINS, PAGESIZE, total_pages,
(double)(total_pages * PAGESIZE) / (1024.0*1024.0), total_alloc, misses);
}
@@ -82,6 +88,7 @@
if (sz > BINS || sz == 0) {
misses++;
+ bu_log("missed size %ld\n", sz);
return bu_calloc(1, sz, "heap calloc");
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits