Skip to content

Commit 7a52b19

Browse files
committed
gh-138122: Add some screenshots to the profiling.sampling docs
1 parent c865ab3 commit 7a52b19

10 files changed

+86
-4
lines changed

Doc/library/profiling.sampling.rst

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ and the base instruction.
406406

407407
Opcode information appears in several output formats:
408408

409-
- **Live mode**: An opcode panel shows instruction-level statistics for the
410-
selected function, accessible via keyboard navigation
411-
- **Flame graphs**: Nodes display opcode information when available, helping
412-
identify which instructions consume the most time
409+
- **Flame graphs**: Hovering over a frame displays a tooltip with bytecode
410+
instruction breakdown, showing which opcodes consumed time in that function
413411
- **Heatmap**: Expandable bytecode panels per source line show instruction
414412
breakdown with specialization percentages
413+
- **Live mode**: An opcode panel shows instruction-level statistics for the
414+
selected function, accessible via keyboard navigation
415415
- **Gecko format**: Opcode transitions are emitted as interval markers in the
416416
Firefox Profiler timeline
417417

@@ -679,6 +679,14 @@ deterministic profilers generate. This is the default output format::
679679
python -m profiling.sampling run script.py
680680
python -m profiling.sampling run --pstats script.py
681681

682+
.. figure:: tachyon-pstats.png
683+
:alt: Tachyon pstats terminal output
684+
:align: center
685+
:width: 100%
686+
687+
The pstats format displays profiling results in a color-coded table showing
688+
function hotspots, sample counts, and timing estimates.
689+
682690
Output appears on stdout by default::
683691

684692
Profile Stats (Mode: wall):
@@ -780,6 +788,15 @@ an interactive flame graph visualization::
780788
python -m profiling.sampling run --flamegraph script.py
781789
python -m profiling.sampling run --flamegraph -o profile.html script.py
782790

791+
.. figure:: tachyon-flamegraph.png
792+
:alt: Tachyon interactive flame graph
793+
:align: center
794+
:width: 100%
795+
796+
The flame graph visualization shows call stacks as nested rectangles, with
797+
width proportional to time spent. The sidebar displays runtime statistics,
798+
GIL metrics, and hotspot functions.
799+
783800
If no output file is specified, the profiler generates a filename based on
784801
the process ID (for example, ``flamegraph.12345.html``).
785802

@@ -850,6 +867,34 @@ Firefox Profiler timeline:
850867
For this reason, the :option:`--mode` option is not available with Gecko format;
851868
all relevant data is captured automatically.
852869

870+
.. figure:: tachyon-gecko-calltree.png
871+
:alt: Firefox Profiler Call Tree view
872+
:align: center
873+
:width: 100%
874+
875+
The Call Tree view shows the complete call hierarchy with sample counts
876+
and percentages. The sidebar displays detailed statistics for the
877+
selected function including running time and sample distribution.
878+
879+
.. figure:: tachyon-gecko-flamegraph.png
880+
:alt: Firefox Profiler Flame Graph view
881+
:align: center
882+
:width: 100%
883+
884+
The Flame Graph visualization shows call stacks as nested rectangles.
885+
Functions like ``worker_a``, ``level_1_analyze``, ``level_2_process``,
886+
and ``level_4_compute`` are visible in the call hierarchy.
887+
888+
.. figure:: tachyon-gecko-opcodes.png
889+
:alt: Firefox Profiler Marker Chart with opcodes
890+
:align: center
891+
:width: 100%
892+
893+
The Marker Chart displays interval markers including CPU state, GIL
894+
status, and opcodes. With ``--opcodes`` enabled, bytecode instructions
895+
like ``BINARY_OP_ADD_FLOAT``, ``CALL_PY_EXACT_ARGS``, and
896+
``CALL_LIST_APPEND`` appear as markers showing execution over time.
897+
853898

854899
Heatmap format
855900
--------------
@@ -860,6 +905,15 @@ showing sample counts at the source line level::
860905
python -m profiling.sampling run --heatmap script.py
861906
python -m profiling.sampling run --heatmap -o my_heatmap script.py
862907

908+
.. figure:: tachyon-heatmap.png
909+
:alt: Tachyon heatmap visualization
910+
:align: center
911+
:width: 100%
912+
913+
The heatmap overlays sample counts directly on your source code. Lines are
914+
color-coded from cool (few samples) to hot (many samples). Navigation
915+
buttons (▲▼) let you jump between callers and callees.
916+
863917
Unlike other formats that produce a single file, heatmap output creates a
864918
directory containing HTML files for each profiled source file. If no output
865919
path is specified, the directory is named ``heatmap_PID``.
@@ -886,6 +940,18 @@ The heatmap interface provides several interactive features:
886940
- **Dark/light theme**: toggle with preference saved across sessions
887941
- **Line linking**: click line numbers to create shareable URLs
888942

943+
When opcode-level profiling is enabled with :option:`--opcodes`, each hot line
944+
can be expanded to show which bytecode instructions consumed time:
945+
946+
.. figure:: tachyon-heatmap-with-opcodes.png
947+
:alt: Heatmap with expanded bytecode panel
948+
:align: center
949+
:width: 100%
950+
951+
Expanding a hot line reveals the bytecode instructions executed, including
952+
specialized variants. The panel shows sample counts per instruction and the
953+
overall specialization percentage for the line.
954+
889955
Heatmaps are especially useful when you know which file contains a performance
890956
issue but need to identify the specific lines. Many developers prefer this
891957
format because it maps directly to their source code, making it easy to read
@@ -903,6 +969,14 @@ data, similar to the ``top`` command for system processes::
903969
python -m profiling.sampling run --live script.py
904970
python -m profiling.sampling attach --live 12345
905971

972+
.. figure:: tachyon-live-mode-2.gif
973+
:alt: Tachyon live mode showing all threads
974+
:align: center
975+
:width: 100%
976+
977+
Live mode displays real-time profiling statistics showing combined
978+
statistics from multiple threads in a multi-threaded application.
979+
906980
The display updates continuously as new samples arrive, showing the current
907981
hottest functions. This mode requires the :mod:`curses` module, which is
908982
available on Unix-like systems but not on Windows. The terminal must be at
@@ -918,6 +992,14 @@ main table, showing instruction-level statistics for the currently selected
918992
function. This panel displays which bytecode instructions are executing most
919993
frequently, including specialized variants and their base opcodes.
920994

995+
.. figure:: tachyon-live-mode-1.gif
996+
:alt: Tachyon live mode with opcode panel
997+
:align: center
998+
:width: 100%
999+
1000+
Live mode with ``--opcodes`` enabled shows an opcode panel with bytecode
1001+
instruction breakdown for the selected function.
1002+
9211003

9221004
Keyboard commands
9231005
-----------------

Doc/library/tachyon-flamegraph.png

82.8 KB
Loading
104 KB
Loading
47.6 KB
Loading
61.2 KB
Loading
91.1 KB
Loading

Doc/library/tachyon-heatmap.png

46 KB
Loading
6.17 MB
Loading
3.39 MB
Loading

Doc/library/tachyon-pstats.png

145 KB
Loading

0 commit comments

Comments
 (0)