You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/commands/running.rst
+16-20Lines changed: 16 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,14 @@ Running
3
3
4
4
Running, restarting, or stopping the program.
5
5
6
-
When a program is stopped there are several possibilities for further
6
+
When a program is stopped, there are several possibilities for further
7
7
program execution. You can:
8
8
9
9
* terminate the program inside the debugger
10
10
* restart the program
11
11
* continue its execution until it would normally terminate or until a
12
12
breakpoint is hit
13
-
* step execution which is runs for a limited amount of code before stopping
13
+
* step execution, which runs for a limited amount of code before stopping
14
14
15
15
About Debugging Overhead
16
16
------------------------
@@ -19,23 +19,22 @@ Explanation of Problem
19
19
~~~~~~~~~~~~~~~~~~~~~~
20
20
21
21
When you enable the debugger, there are callbacks made in the running
22
-
of the program when certain events happen. Events are things occur in
22
+
of the program when certain events happen. Events are things that occur in
23
23
running the program, like when the code reaches a new line in the
24
-
program, when a call or return occur, or when an exception is raised.
24
+
program, when a call or return occurs, or when an exception is raised.
25
25
26
26
The overhead in running these callbacks slows down your
27
27
program. Currently, the overhead can be greater than the overhead in
28
28
``pdb``. This is because the debugger tries to be more precise and
29
-
careful it tracing, and the features it provides are more powerful. In
30
-
most cases, we can do this without a significatn slow down in the
29
+
careful in its tracing, and the features it provides are more powerful. In
30
+
most cases, we can do this without a significant slowdown in the
31
31
debugged program.
32
32
33
33
But in certain situations, the overhead in running debugged code can
34
34
be large. This happens when we want to "step over" a function that is
35
-
large and complex like an ``import`` of a large module.
35
+
large and complex, like an ``import`` of a large module.
36
36
37
-
For example, if you turn on the debugger and run the ``import pandas``
38
-
instruction, it can increase your CPU for a while. ::
37
+
For example, if you turn on the debugger and run the ``import pandas`` instruction, it can increase your CPU usage for a while. ::
39
38
40
39
$ cat slow.py
41
40
#!/usr/bin/env python3
@@ -55,7 +54,7 @@ The debugger overhead only concerns the instructions of the program to
55
54
be debugged, the instructions of the trepan3k interpreter are not
56
55
analyzed.
57
56
58
-
Given this, here is how to speed up the above ::
57
+
Given this, here is how to speed up the above ::
59
58
60
59
$ trepan3k slow.py
61
60
(/tmp/slow.py:1): <module>
@@ -67,7 +66,7 @@ Given this, here is how to speed up the above ::
67
66
(/tmp/slow.py:2 @10): <module>
68
67
-- 2 print(pd)
69
68
70
-
Alternatively, modifying the program with a call to ``debug`` will also run fast::
69
+
Alternatively, modifying the program with a call to ``debug`` will also run fast::
71
70
72
71
$ cat fast.py
73
72
#!/usr/bin/env python3
@@ -92,10 +91,9 @@ Techniques to Reduce Debugger Overhead
92
91
93
92
#. Remove keep breakpoints when you no longer need them
94
93
95
-
When there are *any* breakpoints in the program, the debugger has to
96
-
check every event to see if the event is the target of a breakpoint.
94
+
When there are *any* breakpoints in the program, the debugger has to check every event to see if the event is the target of a breakpoint.
97
95
98
-
In particular the ``continue``, ``finish``, and ``next`` (step over) commands are much slower.
96
+
In particular, the ``continue``, ``finish``, and ``next`` (step over) commands are much slower.
99
97
100
98
Therefore, remove *all* breakpoints when they are no longer
101
99
needed. Consider using temporary or one-time breakpoints when you need to stop only once.
@@ -105,20 +103,18 @@ needed. Consider using temporary or one-time breakpoints when you need to stop o
105
103
106
104
``continue`` when there are no breakpoints pending probably gives the
107
105
fastest execution. ``info break`` will show you if there are any
108
-
breakpoints. Recall that one-time breakopints are removed after they
106
+
breakpoints. Recall that one-time breakpoints are removed after they
109
107
are encountered.
110
108
111
-
When there are no breakpoints using the ``continue`` command will cause
112
-
the debugger will remove its trace hook, and execution should continue at normal speed.
109
+
When no breakpoints are used, the ``continue`` command will cause the debugger to remove its trace hook, and execution should continue at normal speed.
113
110
114
111
The ``step`` is usually fast, because there is generally very little
115
112
debugger overhead between stopping points.
116
113
117
-
The ``next`` (step over) debugger command is faster without breakpoint
118
-
than when there are breakpoint because without breakpoints there is
114
+
The ``next`` (step over) debugger command is faster without a breakpoint than when there are breakpoint because without breakpoints, there is
119
115
less debugger overhead in checking for the stopping condition.
120
116
121
-
The ``finish`` command when there are no breakpoint is faster than when there are breakpoints.
117
+
The ``finish`` command when there are no breakpoints is faster than when there are breakpoints.
122
118
Without breakpoints debugger will remove tracing calls.
123
119
124
120
When there must breakpoint in use, setting a breakpoint and running
0 commit comments