[Python-Dev] tiny optimization in ceval mainloop
by Jeremy Hylton other posts by this author
Aug 29 2002 11:28PM messages near this date
[Python-Dev] single ticker patch
|
Re: [Python-Dev] tiny optimization in ceval mainloop
I noticed that one frequently executed line in the mainloop is testing
whether either the ticker has dropped to 0 or if there are
things_to_do. Would it be kosher to just drop the ticker to 0 whenever
things_to_do is set to true? Then you'd only need to check the ticker
each time through.
Jeremy
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.332
diff -c -c -r2.332 ceval.c
*** ceval.c 23 Aug 2002 14:11:35 -0000 2.332
--- ceval.c 29 Aug 2002 23:19:18 -0000
***************
*** 378,383 ****
--- 378,384 ----
int
Py_AddPendingCall(int (*func)(void *), void *arg)
{
+ PyThreadState *tstate;
static int busy = 0;
int i, j;
/* XXX Begin critical section */
***************
*** 395,400 ****
--- 396,404 ----
pendingcalls[i].func = func;
pendingcalls[i].arg = arg;
pendinglast = j;
+
+ tstate = PyThreadState_GET();
+ tstate-> ticker = 0;
things_to_do = 1; /* Signal main loop */
busy = 0;
/* XXX End critical section */
***************
*** 669,675 ****
async I/O handler); see Py_AddPendingCall() and
Py_MakePendingCalls() above. */
! if (things_to_do || --tstate-> ticker < 0) {
tstate-> ticker = tstate->interp->checkinterval;
if (things_to_do) {
if (Py_MakePendingCalls() < 0) {
--- 673,679 ----
async I/O handler); see Py_AddPendingCall() and
Py_MakePendingCalls() above. */
! if (--tstate-> ticker < 0) {
tstate-> ticker = tstate->interp->checkinterval;
if (things_to_do) {
if (Py_MakePendingCalls() < 0) {
_______________________________________________
Python-Dev mailing list
Python-Dev@[...].org
http://mail.python.org/mailman/listinfo/python-dev
Thread:
Jeremy Hylton
Guido van Rossum
Greg Ewing
Skip Montanaro
Steve Holden
Steve Holden
Jeremy Hylton
Jack Jansen
Tim Peters
Guido van Rossum
Skip Montanaro
Tim Peters
Jack Jansen
Tim Peters
Jack Jansen
Guido van Rossum
Tim Peters
Skip Montanaro
Skip Montanaro
Guido van Rossum
Skip Montanaro
Guido van Rossum
Jeremy Hylton
Guido van Rossum
Tim Peters
|