[pypy-commit] pypy fix-vmprof-stacklet-switch-2: fix test_sampling_inside_callback by restarting sampling inside

antocuni pypy.commits at gmail.com
Tue Nov 28 11:50:16 EST 2017


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: fix-vmprof-stacklet-switch-2
Changeset: r93199:44449d69030b
Date: 2017-11-28 17:49 +0100
http://bitbucket.org/pypy/pypy/changeset/44449d69030b/

Log:	fix test_sampling_inside_callback by restarting sampling inside
	new_stacklet_callback, after it was stopped inside switch().

	This fix is a bit obscure because one pairt of start/stop is inside
	rstacklet.switch, while the other is in interp_continuation. OTOH,
	if we do the fix inside rstacklet we need to replicate it for every
	GcRootFinder, which is also obscure and a nightmare to test. Note
	sure what is the least ugly :(

diff --git a/pypy/module/_continuation/interp_continuation.py b/pypy/module/_continuation/interp_continuation.py
--- a/pypy/module/_continuation/interp_continuation.py
+++ b/pypy/module/_continuation/interp_continuation.py
@@ -1,5 +1,6 @@
 from rpython.rlib.rstacklet import StackletThread
 from rpython.rlib import jit
+from rpython.rlib import rvmprof
 from pypy.interpreter.error import OperationError, get_cleared_operation_error
 from pypy.interpreter.executioncontext import ExecutionContext
 from pypy.interpreter.baseobjspace import W_Root
@@ -222,12 +223,15 @@
     self.h = h
     global_state.clear()
     try:
+        rvmprof.start_sampling()
         frame = self.bottomframe
         w_result = frame.execute_frame()
     except Exception as e:
         global_state.propagate_exception = e
     else:
         global_state.w_value = w_result
+    finally:
+        rvmprof.stop_sampling()
     self.sthread.ec.topframeref = jit.vref_None
     global_state.origin = self
     global_state.destination = self


More information about the pypy-commit mailing list