Revision: 55599
http://sourceforge.net/p/brlcad/code/55599
Author: starseeker
Date: 2013-05-30 00:15:39 +0000 (Thu, 30 May 2013)
Log Message:
-----------
defines aren't public - nix BU_ prefix.
Modified Paths:
--------------
brlcad/trunk/src/libbu/heap.c
Modified: brlcad/trunk/src/libbu/heap.c
===================================================================
--- brlcad/trunk/src/libbu/heap.c 2013-05-30 00:09:11 UTC (rev 55598)
+++ brlcad/trunk/src/libbu/heap.c 2013-05-30 00:15:39 UTC (rev 55599)
@@ -28,21 +28,21 @@
* memory allocations. Any request outside this range will get passed
* to bu_calloc().
*
- * 1-to-BU_HEAP_BINS byte size allocations are allocated in PAGESIZE chunks as
+ * 1-to-HEAP_BINS byte size allocations are allocated in PAGESIZE chunks as
* they are requested. There's minimal penalty for making this
* arbitrarily large except where there are very few allocations (each
* size will allocate at least one page). PAGESIZE should be some
- * multiple larger than BU_HEAP_BINS.
+ * multiple larger than HEAP_BINS.
*
* Embedded or memory-constrained environments probably want to set
* this a lot smaller than the default.
*/
-#define BU_HEAP_BINS 1024
+#define HEAP_BINS 1024
/**
* This specifies how much memory we should preallocate for each
* allocation size. Note that this number should be some multiple of
- * BU_HEAP_BINS and system page size in order to be useful. Ideally sized to
+ * HEAP_BINS and system page size in order to be useful. Ideally sized to
* keep the allocation size with the most requests down to
* single-digit page counts. Testing showed a 1M page size was very
* effective at eliminating allocation overhead.
@@ -50,7 +50,7 @@
* Embedded or memory-constrained environments probably want to set
* this a lot smaller than the default.
*/
-#define BU_HEAP_PAGESIZE (BU_HEAP_BINS * 1024)
+#define HEAP_PAGESIZE (HEAP_BINS * 1024)
struct heap {
@@ -75,7 +75,7 @@
struct cpus {
/** each allocation size gets a bin for holding memory pages */
- struct heap heap[BU_HEAP_BINS];
+ struct heap heap[HEAP_BINS];
/** keep track of allocation sizes outside our supported range */
size_t misses;
@@ -112,14 +112,14 @@
"-----------------------\n");
for (h=0; h < ncpu; h++) {
- for (i=0; i < BU_HEAP_BINS; i++) {
+ for (i=0; i < HEAP_BINS; i++) {
/* capacity across all pages */
- got = per_cpu[h].heap[i].count * (BU_HEAP_PAGESIZE/(i+1));
+ got = per_cpu[h].heap[i].count * (HEAP_PAGESIZE/(i+1));
if (got > 0) {
/* last page is partial */
- got -= (BU_HEAP_PAGESIZE - per_cpu[h].heap[i].given)/(i+1);
+ got -= (HEAP_PAGESIZE - per_cpu[h].heap[i].given)/(i+1);
bu_log("%04zu [%02zu] => %zu\n", i, per_cpu[h].heap[i].count,
got);
allocs += got;
}
@@ -133,7 +133,7 @@
"Page size: %d bytes\n"
"Pages: %zu (%.2lfMB)\n"
"%zu allocs, %zu misses\n"
- "=======================\n", BU_HEAP_BINS, BU_HEAP_PAGESIZE,
total_pages, (double)(total_pages * BU_HEAP_PAGESIZE) / (1024.0*1024.0),
allocs, misses);
+ "=======================\n", HEAP_BINS, HEAP_PAGESIZE, total_pages,
(double)(total_pages * HEAP_PAGESIZE) / (1024.0*1024.0), allocs, misses);
}
@@ -149,7 +149,7 @@
/* what thread are we? */
oncpu = bu_parallel_id();
- if (sz > BU_HEAP_BINS || sz == 0) {
+ if (sz > HEAP_BINS || sz == 0) {
per_cpu[oncpu].misses++;
if (bu_debug) {
@@ -174,15 +174,15 @@
heap->count++;
heap->pages = (char **)bu_malloc(1 * sizeof(char *), "heap malloc
pages[]");
- heap->pages[0] = (char *)bu_calloc(1, BU_HEAP_PAGESIZE, "heap calloc
pages[][0]");
+ heap->pages[0] = (char *)bu_calloc(1, HEAP_PAGESIZE, "heap calloc
pages[][0]");
heap->given = 0;
}
/* grow */
- if (heap->given+sz > BU_HEAP_PAGESIZE) {
+ if (heap->given+sz > HEAP_PAGESIZE) {
heap->count++;
heap->pages = (char **)bu_realloc(heap->pages, heap->count *
sizeof(char *), "heap realloc pages[]");
- heap->pages[heap->count-1] = (char *)bu_calloc(1, BU_HEAP_PAGESIZE,
"heap calloc pages[][]");
+ heap->pages[heap->count-1] = (char *)bu_calloc(1, HEAP_PAGESIZE, "heap
calloc pages[][]");
heap->given = 0;
}
@@ -197,7 +197,7 @@
void
bu_heap_put(void *ptr, size_t sz)
{
- if (sz > BU_HEAP_BINS || sz == 0) {
+ if (sz > HEAP_BINS || sz == 0) {
bu_free(ptr, "heap free");
return;
}
@@ -221,7 +221,7 @@
srand(time(0));
for (i=0; i<1024*1024*50; i++) {
- size_t sz = (((double)rand() / (double)(RAND_MAX-1)) *
(double)BU_HEAP_BINS) + 1;
+ size_t sz = (((double)rand() / (double)(RAND_MAX-1)) *
(double)HEAP_BINS) + 1;
bu_log("allocating %d: %zd\n", i, sz);
#ifdef USE_MALLOC
ptr = malloc(sz);
@@ -266,7 +266,7 @@
/* sanity */
-#if BU_HEAP_PAGESIZE < BU_HEAP_BINS
+#if HEAP_PAGESIZE < HEAP_BINS
# error "ERROR: heap page size cannot be smaller than bin range"
#endif
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits