|
From: Nicholas N. <nj...@cs...> - 2005-05-20 20:40:04
|
SVN commit 416181 by nethercote:
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.
MERGED FROM 3.0 REPOSITORY
M +23 -17 trunk/valgrind/coregrind/vg_malloc2.c =20
--- trunk/valgrind/coregrind/vg_malloc2.c #416180:416181
@@ -40,7 +40,7 @@
/*--- Main types ---*/
/*------------------------------------------------------------*/
=20
-#define VG_N_MALLOC_LISTS 16 // do not change this
+#define VG_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))
@@ -578,22 +578,28 @@
{
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?
|