New submission from Xavier de Gaye:

When f_trace is NULL, only PyTrace_CALL tracing events trigger the invocation of
the trace function (see trace_trampoline).
maybe_call_line_trace() does quite some work though _PyCode_CheckLineNumber to
find out if the instruction should be traced, and all this work is useless when 
f_trace
is NULL. The patch checks for f_trace on all tracing events that are not
PyTrace_CALL.

The performance gain with the following test is about 30%. The first test is
with python on the default branch, the second one with the patch applied.
Note: a breakpoint is set at line 1 to ensure that tracing is enabled, without
any breakpoint, pdb sets the trace function to None after a continue.

$ ./python -m pdb /tmp/foo.py
> /tmp/foo.py(1)<module>()
-> import timeit
(Pdb) break 1
Breakpoint 1 at /tmp/foo.py:1
(Pdb) continue
9.226385930000106
The program finished and will be restarted
> /tmp/foo.py(1)<module>()
-> import timeit
(Pdb) q
[62276 refs]


$ ./python -m pdb /tmp/foo.py 
> /tmp/foo.py(1)<module>()
-> import timeit
(Pdb) break 1
Breakpoint 1 at /tmp/foo.py:1
(Pdb) continue
7.199809867001022
The program finished and will be restarted
> /tmp/foo.py(1)<module>()
-> import timeit
(Pdb)

----------
components: Interpreter Core
files: f_trace_perfs.diff
keywords: patch
messages: 177390
nosy: xdegaye
priority: normal
severity: normal
status: open
title: improve tracing performances when f_trace is NULL
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file28297/f_trace_perfs.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16672>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to