]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Follow up to r15253:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 17 May 2015 21:36:05 +0000 (21:36 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 17 May 2015 21:36:05 +0000 (21:36 +0000)
Having a one elt free lineF cache avoids many PA calls.
This seems to slightly improve (a few %) a firefox startup.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15254

helgrind/libhb_core.c

index 23acf595d38ea977c544e244ded33a3efabad8b8..d507394502ab54b3890eea65044bf80dbe1502b8 100644 (file)
@@ -1007,6 +1007,11 @@ static UWord read_twobit_array ( UChar* arr, UWord ix ) {
    return (arr[bix] >> shft) & 3;
 }
 
+/* We cache one free lineF, to avoid pool allocator calls.
+   Measurement on firefox has shown that this avoids more than 90%
+   of the PA calls. */
+static LineF *free_lineF = NULL;
+
 /* Allocates a lineF for LineZ. Sets lineZ in a state indicating
    lineF has to be used. */
 static inline LineF *alloc_LineF_for_Z (LineZ *lineZ)
@@ -1015,7 +1020,12 @@ static inline LineF *alloc_LineF_for_Z (LineZ *lineZ)
 
    tl_assert(lineZ->dict[0] == SVal_INVALID);
 
-   lineF = VG_(allocEltPA) ( LineF_pool_allocator );
+   if (LIKELY(free_lineF)) {
+      lineF = free_lineF;
+      free_lineF = NULL;
+   } else {
+      lineF = VG_(allocEltPA) ( LineF_pool_allocator );
+   }
    lineZ->dict[0] = lineZ->dict[2] = lineZ->dict[3] = SVal_INVALID;
    lineZ->dict[1] = Ptr2SVal (lineF);
 
@@ -1030,7 +1040,11 @@ static inline void clear_LineF_of_Z (LineZ *lineZ)
    LineF *lineF = LineF_Ptr(lineZ);
 
    rcdec_LineF(lineF);
-   VG_(freeEltPA)( LineF_pool_allocator, lineF );
+   if (UNLIKELY(free_lineF)) {
+      VG_(freeEltPA)( LineF_pool_allocator, lineF );
+   } else {
+      free_lineF = lineF;
+   }
    lineZ->dict[0] = SVal_NOACCESS;
    lineZ->dict[1] = SVal_INVALID;
 }