[Python-checkins] r75632 - in sandbox/trunk/newgil: Include/ceval.h Include/pystate.h Include/sysmodule.h Objects/longobject.c Python/ceval.c Python/sysmodule.c

antoine.pitrou python-checkins at python.org
Fri Oct 23 19:56:42 CEST 2009


Author: antoine.pitrou
Date: Fri Oct 23 19:56:41 2009
New Revision: 75632

Log:
_Py_Ticker was not quite dead



Modified:
   sandbox/trunk/newgil/Include/ceval.h
   sandbox/trunk/newgil/Include/pystate.h
   sandbox/trunk/newgil/Include/sysmodule.h
   sandbox/trunk/newgil/Objects/longobject.c
   sandbox/trunk/newgil/Python/ceval.c
   sandbox/trunk/newgil/Python/sysmodule.c

Modified: sandbox/trunk/newgil/Include/ceval.h
==============================================================================
--- sandbox/trunk/newgil/Include/ceval.h	(original)
+++ sandbox/trunk/newgil/Include/ceval.h	Fri Oct 23 19:56:41 2009
@@ -112,10 +112,6 @@
 PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
 PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
 
-/* this used to be handled on a per-thread basis - now just two globals */
-// PyAPI_DATA(volatile int) _Py_Ticker;
-PyAPI_DATA(int) _Py_CheckInterval;
-
 /* Interface for threads.
 
    A module that plans to do a blocking system call (or something else

Modified: sandbox/trunk/newgil/Include/pystate.h
==============================================================================
--- sandbox/trunk/newgil/Include/pystate.h	(original)
+++ sandbox/trunk/newgil/Include/pystate.h	Fri Oct 23 19:56:41 2009
@@ -88,6 +88,8 @@
 
     PyObject *dict;  /* Stores per-thread state */
 
+    /* XXX doesn't mean anything anymore (the comment below is obsolete)
+       => deprecate or remove? */
     /* tick_counter is incremented whenever the check_interval ticker
      * reaches zero. The purpose is to give a useful measure of the number
      * of interpreted bytecode instructions in a given thread.  This

Modified: sandbox/trunk/newgil/Include/sysmodule.h
==============================================================================
--- sandbox/trunk/newgil/Include/sysmodule.h	(original)
+++ sandbox/trunk/newgil/Include/sysmodule.h	Fri Oct 23 19:56:41 2009
@@ -18,7 +18,6 @@
 			Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
 
 PyAPI_DATA(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc;
-PyAPI_DATA(int) _PySys_CheckInterval;
 
 PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
 PyAPI_FUNC(void) PySys_AddWarnOption(const wchar_t *);

Modified: sandbox/trunk/newgil/Objects/longobject.c
==============================================================================
--- sandbox/trunk/newgil/Objects/longobject.c	(original)
+++ sandbox/trunk/newgil/Objects/longobject.c	Fri Oct 23 19:56:41 2009
@@ -95,14 +95,6 @@
 #define MAX(x, y) ((x) < (y) ? (y) : (x))
 #define MIN(x, y) ((x) > (y) ? (y) : (x))
 
-#if 0
-#define SIGCHECK(PyTryBlock) \
-	if (--_Py_Ticker < 0) { \
-		_Py_Ticker = _Py_CheckInterval; \
-		if (PyErr_CheckSignals()) PyTryBlock \
-	}
-#endif
-
 #define SIGCHECK(PyTryBlock) \
 	if (PyErr_CheckSignals()) PyTryBlock \
 

Modified: sandbox/trunk/newgil/Python/ceval.c
==============================================================================
--- sandbox/trunk/newgil/Python/ceval.c	(original)
+++ sandbox/trunk/newgil/Python/ceval.c	Fri Oct 23 19:56:41 2009
@@ -236,6 +236,7 @@
 static volatile int gil_drop_request = 0;
 /* Request for running pending calls */
 static volatile int pendingcalls_to_do = 0; 
+/* Request for looking at the `async_exc` field of the current thread state */
 static volatile int pending_async_exc = 0;
 
 #include "ceval_pthread.h"
@@ -270,8 +271,8 @@
 void
 PyEval_ReleaseLock(void)
 {
-	/* This function must succeed when the current thread state is NULL,
-	   therefore we avoid PyThreadState_GET() which prints a fatal error
+	/* This function must succeed when the current thread state is NULL.
+	   We therefore avoid PyThreadState_GET() which dumps a fatal error
 	   in debug mode.
 	*/
 	drop_gil(_PyThreadState_Current);
@@ -473,7 +474,6 @@
 		pendinglast = j;
 	}
 	/* signal main loop */
-// 	_Py_Ticker = 0;
 	SIGNAL_PENDING_CALLS();
 	if (lock != NULL)
 		PyThread_release_lock(lock);
@@ -520,7 +520,6 @@
 			SIGNAL_PENDING_CALLS();
 		else
 			UNSIGNAL_PENDING_CALLS();
-// 		pendingcalls_to_do = pendingfirst != pendinglast;
 		PyThread_release_lock(pending_lock);
 		/* having released the lock, perform the callback */
 		if (func == NULL)
@@ -705,11 +704,6 @@
    fast_next_opcode*/
 static int _Py_TracingPossible = 0;
 
-/* for manipulating the thread switch and periodic "stuff" - used to be
-   per thread, now just a pair o' globals */
-int _Py_CheckInterval = 1000;
-// volatile int _Py_Ticker = 0; /* so that we hit a "tick" first thing */
-
 
 
 PyObject *
@@ -1214,14 +1208,12 @@
 		   async I/O handler); see Py_AddPendingCall() and
 		   Py_MakePendingCalls() above. */
 
-// 		if (--_Py_Ticker < 0) {
 		if (eval_breaker) {
 			if (*next_instr == SETUP_FINALLY) {
 				/* Make the last opcode before
 				   a try: finally: block uninterruptable. */
 				goto fast_next_opcode;
 			}
-// 			_Py_Ticker = _Py_CheckInterval;
 			tstate->tick_counter++;
 #ifdef WITH_TSC
 			ticked = 1;
@@ -1231,14 +1223,7 @@
 					why = WHY_EXCEPTION;
 					goto on_error;
 				}
-// 				if (pendingcalls_to_do)
-					/* MakePendingCalls() didn't succeed.
-					   Force early re-execution of this
-					   "periodic" code, possibly after
-					   a thread switch */
-// 					_Py_Ticker = 0;
 			}
-// 		}
 			if (gil_drop_request) {
 #ifdef WITH_THREAD
 				/* Give another thread a chance */

Modified: sandbox/trunk/newgil/Python/sysmodule.c
==============================================================================
--- sandbox/trunk/newgil/Python/sysmodule.c	(original)
+++ sandbox/trunk/newgil/Python/sysmodule.c	Fri Oct 23 19:56:41 2009
@@ -441,6 +441,9 @@
 	return temp;
 }
 
+/* TODO: deprecate */
+static int _check_interval = 100;
+
 PyDoc_STRVAR(getprofile_doc,
 "getprofile()\n\
 \n\
@@ -451,7 +454,7 @@
 static PyObject *
 sys_setcheckinterval(PyObject *self, PyObject *args)
 {
-	if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval))
+	if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_check_interval))
 		return NULL;
 	Py_INCREF(Py_None);
 	return Py_None;
@@ -467,7 +470,7 @@
 static PyObject *
 sys_getcheckinterval(PyObject *self, PyObject *args)
 {
-	return PyLong_FromLong(_Py_CheckInterval);
+	return PyLong_FromLong(_check_interval);
 }
 
 PyDoc_STRVAR(getcheckinterval_doc,


More information about the Python-checkins mailing list