diff options
| author | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-12-12 17:39:28 (GMT) |
|---|---|---|
| committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-12-12 17:39:28 (GMT) |
| commit | c2222978502ff08cbaeac423621c4e2c05a131cf (patch) | |
| tree | 6608da7eb5a8f6c04a45496db10207f445b93b7c /Python | |
| parent | 8812e95df703280aa12e1ed3c5bcc3819e10f1ca (diff) | |
| download | cpython-c2222978502ff08cbaeac423621c4e2c05a131cf.zip cpython-c2222978502ff08cbaeac423621c4e2c05a131cf.tar.gz cpython-c2222978502ff08cbaeac423621c4e2c05a131cf.tar.bz2 | |
Unblocked and merged revisions 67611 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r67611 | jeffrey.yasskin | 2008-12-06 09:09:27 -0800 (Sat, 06 Dec 2008) | 11 lines
Merged revisions 67494 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67494 | jeffrey.yasskin | 2008-12-02 22:46:45 -0800 (Tue, 02 Dec 2008) | 5 lines
Speed up Python (according to pybench and 2to3-on-itself) by 1-2% by caching
whether any thread has tracing turned on, which saves one load instruction in
the fast_next_opcode path in PyEval_EvalFrameEx(). See issue 4477.
........
................
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/ceval.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index c423c9f..b17d3db 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -508,6 +508,13 @@ enum why_code { static enum why_code do_raise(PyObject *, PyObject *); static int unpack_iterable(PyObject *, int, int, PyObject **); +/* Records whether tracing is on for any thread. Counts the number of + threads for which tstate->c_tracefunc is non-NULL, so if the value + is 0, we know we don't have to check this thread's c_tracefunc. + This speeds up the if statement in PyEval_EvalFrameEx() after + 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 = 100; @@ -957,7 +964,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) /* line-by-line tracing support */ - if (tstate->c_tracefunc != NULL && !tstate->tracing) { + if (_Py_TracingPossible && + tstate->c_tracefunc != NULL && !tstate->tracing) { /* see maybe_call_line_trace for expository comments */ f->f_stacktop = stack_pointer; @@ -3188,6 +3196,7 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg) { PyThreadState *tstate = PyThreadState_GET(); PyObject *temp = tstate->c_traceobj; + _Py_TracingPossible += (func != NULL) - (tstate->c_tracefunc != NULL); Py_XINCREF(arg); tstate->c_tracefunc = NULL; tstate->c_traceobj = NULL; |
