|
From: <sv...@va...> - 2005-05-19 10:54:05
|
Author: sewardj
Date: 2005-05-19 11:54:01 +0100 (Thu, 19 May 2005)
New Revision: 3776
Modified:
trunk/coregrind/m_mallocfree.c
Log:
Small but critical performance fix from Pete Moceyunas: give
each small allocation size its own list. Otherwise there can
be very long searches along lists looking for a block of the
right size.
Modified: trunk/coregrind/m_mallocfree.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_mallocfree.c 2005-05-19 07:32:05 UTC (rev 3775)
+++ trunk/coregrind/m_mallocfree.c 2005-05-19 10:54:01 UTC (rev 3776)
@@ -44,7 +44,7 @@
/*--- Main types ---*/
/*------------------------------------------------------------*/
=20
-#define N_MALLOC_LISTS 16 // do not change this
+#define N_MALLOC_LISTS 18 // do not change this
=20
// The amount you can ask for is limited only by sizeof(SizeT)...
#define MAX_PSZB (~((SizeT)0x0))
@@ -533,22 +533,27 @@
{
vg_assert(0 =3D=3D pszB % VG_MIN_MALLOC_SZB);
pszB /=3D VG_MIN_MALLOC_SZB;
- if (pszB <=3D 2) return 0;
- if (pszB <=3D 3) return 1;
- if (pszB <=3D 4) return 2;
- if (pszB <=3D 5) return 3;
- if (pszB <=3D 6) return 4;
- if (pszB <=3D 7) return 5;
- if (pszB <=3D 8) return 6;
- if (pszB <=3D 9) return 7;
- if (pszB <=3D 10) return 8;
- if (pszB <=3D 11) return 9;
- if (pszB <=3D 12) return 10;
- if (pszB <=3D 16) return 11;
- if (pszB <=3D 32) return 12;
- if (pszB <=3D 64) return 13;
- if (pszB <=3D 128) return 14;
- return 15;
+ switch (pszB) {
+ case 0: return 0;
+ case 1: return 1;
+ case 2: return 2;
+ case 3: return 3;
+ case 4: return 4;
+ case 5: return 5;
+ case 6: return 6;
+ case 7: return 7;
+ case 8: return 8;
+ case 9: return 9;
+ case 10: return 10;
+ case 11: return 11;
+ case 12: return 12;
+ default: break;
+ }
+ if (pszB <=3D 16) return 13;
+ if (pszB <=3D 32) return 14;
+ if (pszB <=3D 64) return 15;
+ if (pszB <=3D 128) return 16;
+ return 17;
}
=20
// What is the minimum payload size for a given list?
|