Revision: 77712
http://sourceforge.net/p/brlcad/code/77712
Author: brlcad
Date: 2020-11-08 07:07:39 +0000 (Sun, 08 Nov 2020)
Log Message:
-----------
modify the test to make sure we can allocate enough.
upon observing and debugging test failures on lower-memory systems,
came to understand more specifically the cause being incredibly
inefficient handling by librt. debugging shows a given allocation
passed in as title ends up creating 9 copies. Due to how AVS are
copied/merged/recopied as they're synced as well as how objects are
serialized for export, there are as many as 5 copies simultaneously!
In order to combat this, we test whether we can allocate in advance
with malloc first, and halt if we can't get 5x the requested amount.
Modified Paths:
--------------
brlcad/trunk/src/gtools/tests/bigdb.c
Modified: brlcad/trunk/src/gtools/tests/bigdb.c
===================================================================
--- brlcad/trunk/src/gtools/tests/bigdb.c 2020-11-07 18:39:42 UTC (rev
77711)
+++ brlcad/trunk/src/gtools/tests/bigdb.c 2020-11-08 07:07:39 UTC (rev
77712)
@@ -50,6 +50,7 @@
#include "common.h"
#include <string.h>
+#include <stdlib.h>
#include "bu.h"
#include "raytrace.h"
@@ -91,8 +92,20 @@
BU_ASSERT((uint64_t)sz < (uint64_t)(SIZE_MAX/2));
BU_ASSERT(sz > strlen("123......321")+1);
- title = (char *)bu_malloc(sz * 2, "test allocation");
- bu_free(title, "test allocation");
+ /* intentionally using malloc so we can halt the test if this
+ * system will let us allocate enough memory.
+ *
+ * unfortunately, librt currently re-allocates a title 9 times in
+ * the process of writing it to disk, keeping what appears to be 5
+ * of them in memory at the same time.
+ */
+#define MULTIPLIER 5
+ title = (char *)malloc(sz * MULTIPLIER);
+ if (!title) {
+ bu_log("WARNING: unable to allocate %zu MB\n", (sz * MULTIPLIER) /
(1024 * 1024));
+ bu_exit(123, "Aborting test.\n");
+ }
+ free(title);
title = (char *)bu_malloc(sz, "title");
memset(title, ' ', sz);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits