Skip to content

Commit 0f99d45

Browse files
Merge remote-tracking branch 'upstream/main' into pr/143171
2 parents 144c38c + b3f2d80 commit 0f99d45

34 files changed

+1155
-964
lines changed

Doc/library/profiling.sampling.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ is unaware it is being profiled.
241241
When profiling production systems, keep these guidelines in mind:
242242

243243
Start with shorter durations (10-30 seconds) to get quick results, then extend
244-
if you need more statistical accuracy. The default 10-second duration is usually
245-
sufficient to identify major hotspots.
244+
if you need more statistical accuracy. By default, profiling runs until the
245+
target process completes, which is usually sufficient to identify major hotspots.
246246

247247
If possible, profile during representative load rather than peak traffic.
248248
Profiles collected during normal operation are easier to interpret than those
@@ -329,7 +329,7 @@ The default configuration works well for most use cases:
329329
* - Default for ``--sampling-rate`` / ``-r``
330330
- 1 kHz
331331
* - Default for ``--duration`` / ``-d``
332-
- 10 seconds
332+
- Run to completion
333333
* - Default for ``--all-threads`` / ``-a``
334334
- Main thread only
335335
* - Default for ``--native``
@@ -363,15 +363,14 @@ cost of slightly higher profiler CPU usage. Lower rates reduce profiler
363363
overhead but may miss short-lived functions. For most applications, the
364364
default rate provides a good balance between accuracy and overhead.
365365

366-
The :option:`--duration` option (:option:`-d`) sets how long to profile in seconds. The
367-
default is 10 seconds::
366+
The :option:`--duration` option (:option:`-d`) sets how long to profile in seconds. By
367+
default, profiling continues until the target process exits or is interrupted::
368368

369369
python -m profiling.sampling run -d 60 script.py
370370

371-
Longer durations collect more samples and produce more statistically reliable
372-
results, especially for code paths that execute infrequently. When profiling
373-
a program that runs for a fixed time, you may want to set the duration to
374-
match or exceed the expected runtime.
371+
Specifying a duration is useful when attaching to long-running processes or when
372+
you want to limit profiling to a specific time window. When profiling a script,
373+
the default behavior of running to completion is usually what you want.
375374

376375

377376
Thread selection
@@ -1394,7 +1393,7 @@ Sampling options
13941393

13951394
.. option:: -d <seconds>, --duration <seconds>
13961395

1397-
Profiling duration in seconds. Default: 10.
1396+
Profiling duration in seconds. Default: run to completion.
13981397

13991398
.. option:: -a, --all-threads
14001399

Include/internal/pycore_opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)