Skip to content

Commit bdbdff5

Browse files
authored
Merge pull request #42 from dev590t/feature/documentation
Add tip about debug overhead
2 parents 8529e3f + e8ba455 commit bdbdff5

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

docs/commands/running.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,61 @@ program execution. You can:
1212
breakpoint is hit
1313
* step exection which is runs for a limited amount of code before stopping
1414

15+
About debugging overhead
16+
------------------------
17+
18+
Explain
19+
~~~~~~~
20+
21+
When you enable the debugger, it adds overhead and slows down your
22+
program. The overhead is greater than pdb, because the debugger tries to
23+
analyze the program in depth. In most cases, this does not diminish the
24+
debugging experience. But for some instructions, the overhead can be
25+
very large.
26+
For example, if you turn on the debugger and run the
27+
\`import pandas\` instruction, it can increase your CPU to 100% for a
28+
while.
29+
::
30+
31+
$ cat tmp.py
32+
#!/usr/bin/env python3
33+
import pandas as pd
34+
35+
$ trepan3k tmp.py
36+
(trepan3k) next # that increase your CPU to 100% for a while
37+
38+
The debugger overhead only concerns the instructions of the program to
39+
be debugged, the instructions of the trepan3k interpreter are not
40+
analyzed, so there is no overhead.
41+
For example, in trepan3k, do an
42+
\`import pandas\` and you will probably see that things are
43+
instantaneous.
44+
::
45+
46+
$ trepan3k tmp.py
47+
(trepan3k) import pandas as pd # that things are instantaneous
48+
49+
Technique to reduce the overhead costs
50+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51+
52+
#. Activate the debugger only when you need it
53+
54+
Look at
55+
https://python3-trepan.readthedocs.io/en/latest/entry-exit.html#calling-the-debugger-from-your-program.
56+
By doing there is no slowdown whatsoever until the first breakpoint
57+
is hit.
58+
59+
#. Use debugging commands with less overhead
60+
61+
Not all commands have the same overhead.
62+
63+
Setting a breakpoint and running "continue" is faster than \`next\`
64+
command. Because \`next\` tries to be more accurate about nexting and
65+
that considerably slows things down.
66+
67+
Debugging commands
68+
------------------
69+
1570
.. toctree::
1671
:maxdepth: 1
1772

0 commit comments

Comments
 (0)