Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r67882:456028ed293d
Date: 2013-11-08 11:40 +0100
http://bitbucket.org/pypy/pypy/changeset/456028ed293d/

Log:    Attempting to reduce the randomness shown on codespeed: split the
        timetable in two parts, one reserved for entering new loops and the
        other reserved for guards.

diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -514,7 +514,8 @@
         #
         if metainterp_sd.warmrunnerdesc is not None:   # for tests
             jitcounter = metainterp_sd.warmrunnerdesc.jitcounter
-            self.status = jitcounter.fetch_next_index() << self.ST_SHIFT
+            index = jitcounter.in_second_half(jitcounter.fetch_next_index())
+            self.status = index << self.ST_SHIFT
 
     def make_a_counter_per_value(self, guard_value_op):
         assert guard_value_op.getopnum() == rop.GUARD_VALUE
@@ -598,7 +599,7 @@
 
             hash = (current_object_addr_as_int(self) * 777767777 +
                     intval * 1442968193)
-            index = jitcounter.get_index(hash)
+            index = jitcounter.in_second_half(jitcounter.get_index(hash))
         #
         increment = jitdriver_sd.warmstate.increment_trace_eagerness
         return jitcounter.tick(index, increment)
diff --git a/rpython/jit/metainterp/counter.py 
b/rpython/jit/metainterp/counter.py
--- a/rpython/jit/metainterp/counter.py
+++ b/rpython/jit/metainterp/counter.py
@@ -18,11 +18,20 @@
         while (UINT32MAX >> self.shift) != size - 1:
             self.shift += 1
             assert self.shift < 999, "size is not a power of two <= 2**31"
-        self.timetable = lltype.malloc(rffi.CArray(rffi.FLOAT), size,
+        #
+        # The table of timings.  The first half is used for starting the
+        # compilation of new loops.  The second half is used for turning
+        # failing guards into bridges.  The two halves are split to avoid
+        # too much interference.
+        self.timetablesize = size * 2
+        self.timetable = lltype.malloc(rffi.CArray(rffi.FLOAT),
+                                       self.timetablesize,
                                        flavor='raw', zero=True,
                                        track_allocation=False)
+        self._nextindex = r_uint(0)
+        #
+        # The table of JitCell entries, recording already-compiled loops
         self.celltable = [None] * size
-        self._nextindex = r_uint(0)
         #
         if translator is not None:
             class Glob:
@@ -61,6 +70,10 @@
         self._nextindex = (result + 1) & self.get_index(-1)
         return result
 
+    def in_second_half(self, index):
+        assert index < r_uint(self.size)
+        return self.size + index
+
     def tick(self, index, increment):
         counter = float(self.timetable[index]) + increment
         if counter < 1.0:
@@ -112,7 +125,7 @@
         # important in corner cases where we would suddenly compile more
         # than one loop because all counters reach the bound at the same
         # time, but where compiling all but the first one is pointless.
-        size = self.size
+        size = self.timetablesize
         pypy__decay_jit_counters(self.timetable, self.decay_by_mult, size)
 
 
@@ -152,6 +165,10 @@
         "NOT_RPYTHON"
         pass
 
+    def in_second_half(self, index):
+        "NOT_RPYTHON"
+        return index + 12345
+
     def _clear_all(self):
         self.timetable.clear()
         self.celltable.clear()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to