Revision: 55051
http://brlcad.svn.sourceforge.net/brlcad/?rev=55051&view=rev
Author: brlcad
Date: 2013-04-05 03:41:34 +0000 (Fri, 05 Apr 2013)
Log Message:
-----------
duh, race condition on initializing the per-cpu structure dynamically.
statically allocate for the compile-time maximum number of cpus. wastefully
consumes 32MB (32KB per cpu with 1024 bins), but avoids a runtime branch and
fixes the problem of how to release the dynamic memory so not all bad.
Modified Paths:
--------------
brlcad/trunk/src/libbu/heap.c
Modified: brlcad/trunk/src/libbu/heap.c
===================================================================
--- brlcad/trunk/src/libbu/heap.c 2013-04-04 22:33:12 UTC (rev 55050)
+++ brlcad/trunk/src/libbu/heap.c 2013-04-05 03:41:34 UTC (rev 55051)
@@ -94,9 +94,10 @@
};
struct cpus {
- struct bins *bin;
+ struct bins bin[BINS];
size_t misses;
-} *per_cpu = NULL;
+};
+static struct cpus per_cpu[MAX_PSW] = {{{{0, 0, 0, 0}}, 0}};
void
@@ -145,15 +146,6 @@
int oncpu;
struct bins *bin;
- /* init per-cpu structures */
- if (!per_cpu) {
- size_t i;
- size_t ncpus = bu_avail_cpus();
- per_cpu = bu_calloc(ncpus, sizeof(struct cpus), "struct cpus");
- for (i=0; i<ncpus; i++)
- per_cpu[i].bin = bu_calloc(BINS, sizeof(struct bins), "struct
bins");
- }
-
/* what thread are we? */
oncpu = bu_parallel_id();
@@ -171,16 +163,14 @@
}
bin = &per_cpu[oncpu].bin[smo];
-
bin->alloc++;
- /* alloc[smo]++; */
/* init */
- if (!bin->pages) {
+ if (bin->pages == 0) {
- if (bu_debug && printit==0) {
- atexit(bu_heap_print);
+ if (bu_debug && printit == 0) {
printit++;
+ atexit(bu_heap_print);
}
bin->pages++;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits