|
From: <sv...@va...> - 2008-08-22 23:16:00
|
Author: sewardj
Date: 2008-08-23 00:16:06 +0100 (Sat, 23 Aug 2008)
New Revision: 8539
Log:
Try and bit a bit more space-economical, by increasing the
average loading factor from 0.75 to 0.83, and by being more
careful in VG_(cloneXA).
Modified:
trunk/coregrind/m_xarray.c
Modified: trunk/coregrind/m_xarray.c
===================================================================
--- trunk/coregrind/m_xarray.c 2008-08-22 14:47:20 UTC (rev 8538)
+++ trunk/coregrind/m_xarray.c 2008-08-22 23:16:06 UTC (rev 8539)
@@ -91,6 +91,13 @@
*nyu = *xa;
/* ... except we have to clone the contents-array */
if (nyu->arr) {
+ /* Restrict the total size of the new array to its current
+ actual size. That means we don't waste space copying the
+ unused tail of the original. The tradeoff is that it
+ guarantees we will have to resize the child if even one more
+ element is later added to it, unfortunately. */
+ nyu->totsizeE = nyu->usedsizeE;
+ /* and allocate .. */
nyu->arr = nyu->alloc( nyu->totsizeE * nyu->elemSzB );
if (!nyu->arr) {
nyu->free(nyu);
@@ -149,9 +156,9 @@
else if (xa->elemSzB == 2) newsz = 4;
else newsz = 2;
} else {
- newsz = 2 * xa->totsizeE;
+ newsz = 1 + (3 * xa->totsizeE) / 2; /* 2 * xa->totsizeE; */
}
- if (0)
+ if (0 && xa->totsizeE >= 10000)
VG_(printf)("addToXA: increasing from %ld to %ld\n",
xa->totsizeE, newsz);
tmp = xa->alloc(newsz * xa->elemSzB);
|