[pypy-svn] r79427 - in pypy/trunk/pypy: config jit/metainterp jit/metainterp/test jit/tool/test rlib translator

arigo at codespeak.net arigo at codespeak.net
Tue Nov 23 19:03:19 CET 2010


Author: arigo
Date: Tue Nov 23 19:03:17 2010
New Revision: 79427

Modified:
   pypy/trunk/pypy/config/translationoption.py
   pypy/trunk/pypy/jit/metainterp/jitprof.py
   pypy/trunk/pypy/jit/metainterp/pyjitpl.py
   pypy/trunk/pypy/jit/metainterp/test/test_basic.py
   pypy/trunk/pypy/jit/metainterp/test/test_compile.py
   pypy/trunk/pypy/jit/metainterp/test/test_warmspot.py
   pypy/trunk/pypy/jit/metainterp/warmspot.py
   pypy/trunk/pypy/jit/metainterp/warmstate.py
   pypy/trunk/pypy/jit/tool/test/test_jitoutput.py
   pypy/trunk/pypy/rlib/jit.py
   pypy/trunk/pypy/translator/driver.py
Log:
Remove the old jit-debug option completely, as well as all places
using it -- there was actually only the Profiler subclasses.  Now
instead, write the summary at the end in the normal (logged) way in
the category "jit-summary".  To enable, you can set the env var

    PYPYLOG=jit-summary:-



Modified: pypy/trunk/pypy/config/translationoption.py
==============================================================================
--- pypy/trunk/pypy/config/translationoption.py	(original)
+++ pypy/trunk/pypy/config/translationoption.py	Tue Nov 23 19:03:17 2010
@@ -114,10 +114,6 @@
     ChoiceOption("jit_backend", "choose the backend for the JIT",
                  ["auto", "x86", "x86-without-sse2", "llvm"],
                  default="auto", cmdline="--jit-backend"),
-    ChoiceOption("jit_debug", "the amount of debugging dumps made by the JIT",
-                 ["off", "profile", "steps", "detailed"],
-                 default="off",
-                 cmdline="--jit-debug"),
     ChoiceOption("jit_profiler", "integrate profiler support into the JIT",
                  ["off", "oprofile"],
                  default="off"),

Modified: pypy/trunk/pypy/jit/metainterp/jitprof.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/jitprof.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/jitprof.py	Tue Nov 23 19:03:17 2010
@@ -2,9 +2,9 @@
 """ A small helper module for profiling JIT
 """
 
-import os
 import time
-from pypy.rlib.debug import debug_print
+from pypy.rlib.debug import debug_print, debug_start, debug_stop
+from pypy.rlib.debug import have_debug_prints
 from pypy.jit.metainterp.jitexc import JitException
 
 counters="""
@@ -48,9 +48,6 @@
     def finish(self):
         pass
 
-    def set_printing(self, printing):
-        pass
-
     def start_tracing(self):
         pass
 
@@ -90,7 +87,6 @@
     counters = None
     calls = 0
     current = None
-    printing = True
 
     def start(self):
         self.starttime = self.timer()
@@ -102,11 +98,7 @@
 
     def finish(self):
         self.tk = self.timer()
-        if self.printing:
-            self.print_stats()
-
-    def set_printing(self, printing):
-        self.printing = printing
+        self.print_stats()
 
     def _start(self, event):
         t0 = self.t1
@@ -154,6 +146,12 @@
             self.calls += 1
 
     def print_stats(self):
+        debug_start("jit-summary")
+        if have_debug_prints():
+            self._print_stats()
+        debug_stop("jit-summary")
+
+    def _print_stats(self):
         cnt = self.counters
         tim = self.times
         calls = self.calls
@@ -161,8 +159,8 @@
         self._print_line_time("Backend", cnt[BACKEND],   tim[BACKEND])
         self._print_intline("Running asm", cnt[RUNNING])
         self._print_intline("Blackhole", cnt[BLACKHOLE])
-        line = "TOTAL:      \t\t%f\n" % (self.tk - self.starttime, )
-        os.write(2, line)
+        line = "TOTAL:      \t\t%f" % (self.tk - self.starttime, )
+        debug_print(line)
         self._print_intline("ops", cnt[OPS])
         self._print_intline("recorded ops", cnt[RECORDED_OPS])
         self._print_intline("  calls", calls)
@@ -178,15 +176,14 @@
         self._print_intline("nvreused", cnt[NVREUSED])
 
     def _print_line_time(self, string, i, tim):
-        final = "%s:%s\t%d\t%f\n" % (string, " " * max(0, 13-len(string)), i, tim)
-        os.write(2, final)
+        final = "%s:%s\t%d\t%f" % (string, " " * max(0, 13-len(string)), i, tim)
+        debug_print(final)
 
     def _print_intline(self, string, i):
         final = string + ':' + " " * max(0, 16-len(string))
-        final += '\t' + str(i) + '\n'
-        os.write(2, final)
-        
-        
+        final += '\t' + str(i)
+        debug_print(final)
+
 
 class BrokenProfilerData(JitException):
     pass

Modified: pypy/trunk/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/pyjitpl.py	Tue Nov 23 19:03:17 2010
@@ -18,7 +18,6 @@
 from pypy.jit.metainterp.jitexc import JitException, get_llexception
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib.objectmodel import specialize
-from pypy.rlib.jit import DEBUG_OFF, DEBUG_PROFILE, DEBUG_STEPS, DEBUG_DETAILED
 from pypy.jit.codewriter.jitcode import JitCode, SwitchDictDescr
 from pypy.jit.codewriter import heaptracker
 

Modified: pypy/trunk/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_basic.py	Tue Nov 23 19:03:17 2010
@@ -35,7 +35,6 @@
         optimize_bridge = staticmethod(simple_optimize.optimize_bridge)
 
         trace_limit = sys.maxint
-        debug_level = 2
 
     func._jit_unroll_safe_ = True
     rtyper = support.annotate(func, values, type_system=type_system)

Modified: pypy/trunk/pypy/jit/metainterp/test/test_compile.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_compile.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_compile.py	Tue Nov 23 19:03:17 2010
@@ -42,7 +42,6 @@
 
 class FakeState:
     optimize_loop = staticmethod(optimize.optimize_loop)
-    debug_level = 0
 
 class FakeGlobalData:
     loopnumbering = 0

Modified: pypy/trunk/pypy/jit/metainterp/test/test_warmspot.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_warmspot.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_warmspot.py	Tue Nov 23 19:03:17 2010
@@ -132,91 +132,6 @@
         assert state.optimize_loop is optimize.optimize_loop
         assert state.optimize_bridge is optimize.optimize_bridge
 
-    def test_static_debug_level(self, capfd):
-        py.test.skip("debug_level is being deprecated")
-        from pypy.rlib.jit import DEBUG_PROFILE, DEBUG_OFF, DEBUG_STEPS
-        from pypy.jit.metainterp.jitprof import EmptyProfiler, Profiler
-        
-        myjitdriver = JitDriver(greens = [], reds = ['n'])
-        def f(n):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n)
-                myjitdriver.jit_merge_point(n=n)
-                n -= 1
-            return n
-
-        capfd.readouterr()
-        self.meta_interp(f, [10], debug_level=DEBUG_OFF,
-                                  ProfilerClass=Profiler)
-        out, err = capfd.readouterr()
-        assert not 'ENTER' in err
-        assert not 'LEAVE' in err
-        assert not "Running asm" in err
-        self.meta_interp(f, [10], debug_level=DEBUG_PROFILE,
-                                  ProfilerClass=Profiler)
-        out, err = capfd.readouterr()
-        assert not 'ENTER' in err
-        assert not 'LEAVE' in err
-        assert not 'compiled new' in err
-        assert "Running asm" in err
-
-        self.meta_interp(f, [10], debug_level=DEBUG_STEPS,
-                                  ProfilerClass=Profiler)
-        out, err = capfd.readouterr()
-        assert 'ENTER' in err
-        assert 'LEAVE' in err
-        assert "Running asm" in err
-
-        self.meta_interp(f, [10], debug_level=DEBUG_STEPS,
-                                  ProfilerClass=EmptyProfiler)
-        out, err = capfd.readouterr()
-        assert 'ENTER' in err
-        assert 'LEAVE' in err
-        assert not "Running asm" in err
-
-    def test_set_param_debug(self):
-        py.test.skip("debug_level is being deprecated")
-        from pypy.rlib.jit import DEBUG_PROFILE, DEBUG_OFF, DEBUG_STEPS
-        from pypy.jit.metainterp.jitprof import EmptyProfiler, Profiler
-        
-        myjitdriver = JitDriver(greens = [], reds = ['n'])
-        def f(n):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n)
-                myjitdriver.jit_merge_point(n=n)
-                n -= 1
-            return n
-
-        def main(n, debug):
-            myjitdriver.set_param("debug", debug)
-            print f(n)
-
-        outerr = py.io.StdCaptureFD()
-        self.meta_interp(main, [10, DEBUG_OFF], debug_level=DEBUG_STEPS,
-                                                ProfilerClass=Profiler)
-        out, errf = outerr.done()
-        err = errf.read()
-        assert not 'ENTER' in err
-        assert not 'LEAVE' in err
-        assert not "Running asm" in err
-        outerr = py.io.StdCaptureFD()
-        self.meta_interp(main, [10, DEBUG_PROFILE], debug_level=DEBUG_STEPS,
-                                                    ProfilerClass=Profiler)
-        out, errf = outerr.done()
-        err = errf.read()
-        assert not 'ENTER' in err
-        assert not 'LEAVE' in err
-        assert not 'compiled new' in err
-        assert "Running asm" in err
-        outerr = py.io.StdCaptureFD()
-        self.meta_interp(main, [10, DEBUG_STEPS], debug_level=DEBUG_OFF,
-                                                  ProfilerClass=Profiler)
-        out, errf = outerr.done()
-        err = errf.read()
-        assert 'ENTER' in err
-        assert 'LEAVE' in err
-        assert "Running asm" in err
-
     def test_unwanted_loops(self):
         mydriver = JitDriver(reds = ['n', 'total', 'm'], greens = [])
 

Modified: pypy/trunk/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/warmspot.py	Tue Nov 23 19:03:17 2010
@@ -24,21 +24,17 @@
 from pypy.jit.metainterp.jitdriver import JitDriverStaticData
 from pypy.jit.codewriter import support, codewriter
 from pypy.jit.codewriter.policy import JitPolicy
-from pypy.rlib.jit import DEBUG_STEPS, DEBUG_DETAILED, DEBUG_OFF, DEBUG_PROFILE
 
 # ____________________________________________________________
 # Bootstrapping
 
-def apply_jit(translator, backend_name="auto", debug_level=DEBUG_STEPS,
-              inline=False,
-              **kwds):
+def apply_jit(translator, backend_name="auto", inline=False, **kwds):
     if 'CPUClass' not in kwds:
         from pypy.jit.backend.detect_cpu import getcpuclass
         kwds['CPUClass'] = getcpuclass(backend_name)
-    if debug_level > DEBUG_OFF:
-        ProfilerClass = Profiler
-    else:
-        ProfilerClass = EmptyProfiler
+    ProfilerClass = Profiler
+    # Always use Profiler here, which should have a very low impact.
+    # Otherwise you can try with ProfilerClass = EmptyProfiler.
     warmrunnerdesc = WarmRunnerDesc(translator,
                                     translate_support_code=True,
                                     listops=True,
@@ -47,7 +43,6 @@
                                     **kwds)
     for jd in warmrunnerdesc.jitdrivers_sd:
         jd.warmstate.set_param_inlining(inline)
-        jd.warmstate.set_param_debug(debug_level)
     warmrunnerdesc.finish()
     translator.warmrunnerdesc = warmrunnerdesc    # for later debugging
 
@@ -66,7 +61,7 @@
 
 def jittify_and_run(interp, graph, args, repeat=1,
                     backendopt=False, trace_limit=sys.maxint,
-                    debug_level=DEBUG_STEPS, inline=False, **kwds):
+                    inline=False, **kwds):
     from pypy.config.config import ConfigError
     translator = interp.typer.annotator.translator
     try:
@@ -83,7 +78,6 @@
         jd.warmstate.set_param_trace_eagerness(2)    # for tests
         jd.warmstate.set_param_trace_limit(trace_limit)
         jd.warmstate.set_param_inlining(inline)
-        jd.warmstate.set_param_debug(debug_level)
     warmrunnerdesc.finish()
     res = interp.eval_graph(graph, args)
     if not kwds.get('translate_support_code', False):

Modified: pypy/trunk/pypy/jit/metainterp/warmstate.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/warmstate.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/warmstate.py	Tue Nov 23 19:03:17 2010
@@ -9,7 +9,6 @@
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.jit import (PARAMETERS, OPTIMIZER_SIMPLE, OPTIMIZER_FULL,
                            OPTIMIZER_NO_PERFECTSPEC)
-from pypy.rlib.jit import DEBUG_PROFILE
 from pypy.rlib.jit import BaseJitCell
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
 from pypy.jit.metainterp import history
@@ -209,11 +208,6 @@
         else:
             raise ValueError("unknown optimizer")
 
-    def set_param_debug(self, value):
-        self.debug_level = value
-        if self.profiler is not None:
-            self.profiler.set_printing(value >= DEBUG_PROFILE)
-
     def disable_noninlinable_function(self, greenkey):
         cell = self.jit_cell_at_key(greenkey)
         cell.dont_trace_here = True

Modified: pypy/trunk/pypy/jit/tool/test/test_jitoutput.py
==============================================================================
--- pypy/trunk/pypy/jit/tool/test/test_jitoutput.py	(original)
+++ pypy/trunk/pypy/jit/tool/test/test_jitoutput.py	Tue Nov 23 19:03:17 2010
@@ -1,10 +1,11 @@
 
 import py
 from pypy.jit.metainterp.warmspot import ll_meta_interp
-from pypy.rlib.jit import JitDriver, DEBUG_PROFILE
+from pypy.rlib.jit import JitDriver
 from pypy.jit.backend.llgraph import runner
 from pypy.jit.metainterp.jitprof import Profiler, JITPROF_LINES
 from pypy.jit.tool.jitoutput import parse_prof
+from pypy.tool.logparser import parse_log, extract_category
 
 def test_really_run():
     """ This test checks whether output of jitprof did not change.
@@ -21,13 +22,15 @@
     cap = py.io.StdCaptureFD()
     try:
         ll_meta_interp(f, [10], CPUClass=runner.LLtypeCPU, type_system='lltype',
-                       ProfilerClass=Profiler, debug_level=DEBUG_PROFILE)
+                       ProfilerClass=Profiler)
     finally:
         out, err = cap.reset()
-    err = "\n".join(err.splitlines()[-JITPROF_LINES:])
-    print err
-    assert err.count("\n") == JITPROF_LINES - 1
-    info = parse_prof(err)
+
+    log = parse_log(err.splitlines(True))
+    err_sections = list(extract_category(log, 'jit-summary'))
+    [err1] = err_sections    # there should be exactly one jit-summary
+    assert err1.count("\n") == JITPROF_LINES
+    info = parse_prof(err1)
     # assert did not crash
     # asserts below are a bit delicate, possibly they might be deleted
     assert info.tracing_no == 1

Modified: pypy/trunk/pypy/rlib/jit.py
==============================================================================
--- pypy/trunk/pypy/rlib/jit.py	(original)
+++ pypy/trunk/pypy/rlib/jit.py	Tue Nov 23 19:03:17 2010
@@ -260,17 +260,11 @@
 OPTIMIZER_NO_PERFECTSPEC = 1
 OPTIMIZER_FULL = 2
 
-DEBUG_OFF = 0
-DEBUG_PROFILE = 1
-DEBUG_STEPS = 2
-DEBUG_DETAILED = 3
-
 PARAMETERS = {'threshold': 1000,
               'trace_eagerness': 200,
               'trace_limit': 10000,
               'inlining': False,
               'optimizer': OPTIMIZER_FULL,
-              'debug' : DEBUG_STEPS,
               }
 unroll_parameters = unrolling_iterable(PARAMETERS.keys())
 

Modified: pypy/trunk/pypy/translator/driver.py
==============================================================================
--- pypy/trunk/pypy/translator/driver.py	(original)
+++ pypy/trunk/pypy/translator/driver.py	Tue Nov 23 19:03:17 2010
@@ -11,7 +11,6 @@
 from pypy.annotation import policy as annpolicy
 import optparse
 from pypy.tool.udir import udir
-from pypy.rlib.jit import DEBUG_OFF, DEBUG_DETAILED, DEBUG_PROFILE, DEBUG_STEPS
 from pypy.rlib.entrypoint import secondary_entrypoints
 
 import py
@@ -37,13 +36,6 @@
     'c': 'lltype',
 }
 
-JIT_DEBUG = {
-    'off' : DEBUG_OFF,
-    'profile' : DEBUG_PROFILE,
-    'steps' : DEBUG_STEPS,
-    'detailed' : DEBUG_DETAILED,
-}
-
 def backend_to_typesystem(backend):
     return _BACKEND_TO_TYPESYSTEM.get(backend, 'ootype')
 
@@ -399,7 +391,6 @@
         #
         from pypy.jit.metainterp.warmspot import apply_jit
         apply_jit(self.translator, policy=self.jitpolicy,
-                  debug_level=JIT_DEBUG[self.config.translation.jit_debug],
                   backend_name=self.config.translation.jit_backend, inline=True)
         #
         self.log.info("the JIT compiler was generated")
@@ -417,7 +408,6 @@
         #
         from pypy.jit.metainterp.warmspot import apply_jit
         apply_jit(self.translator, policy=self.jitpolicy,
-                  debug_level=JIT_DEBUG[self.config.translation.jit_debug],
                   backend_name='cli', inline=True) #XXX
         #
         self.log.info("the JIT compiler was generated")



More information about the Pypy-commit mailing list