[Python-Dev] tiny optimization in ceval mainloop
Guido van Rossum
Fri, 30 Aug 2002 10:13:52 -0400
> Skip> Any time C code would want to read or update ticker, it would have
> Skip> the GIL, right?
> Jack> Not if the idea that lead to this thread (clearing ticker if
> Jack> something is put in things_to_do) is implemented, because we may
> Jack> be in an interrupt routine at the time we fiddle things_to_do.
> Jack> And I don't think we can be sure that even clearing is guaranteed
> Jack> to work (if another thread is halfway a load-decrement-store
> Jack> sequence the clear could be lost).
> Hmm... I guess you lost me. The code that fiddles the ticker in ceval.c
> clearly operates while the GIL is held. I think the code in sysmodule.c
> that updates the checkinterval works under that assumption as well. The
> other ticker in longobject.c I'm not so sure about.
> The patch I submitted doesn't implement the ticker clear that Jeremy
> originally suggested. It just pulls the ticker and the checkinterval out of
> the thread state and makes them two globals. They are both manipulated in
> otherwise the same way.
Yeah, but the whole *point* would be to save an extra test and
(rarely-taken jump) by allowing Jeremy's suggestion to be implemented.
Otherwise I don't see much advantage to the patch (or do you see a
--Guido van Rossum (home page: http://www.python.org/~guido/)