-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
gh-138122: Make the tachyon profiler opcode-aware #142394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 21 commits
dd27e5e
70f2ae0
aedc000
19ff11b
af27d23
7ffe4cb
8b423df
8129e3d
965f521
dac78a5
12c02f6
c10628a
04563f0
f368890
93f7abd
dc127bb
43a298b
a4685fd
b13b6f0
50f63d0
6eed927
1c630ce
56e68c1
e010870
ede0f79
f838c5d
13ecd61
66610ff
aab1f3c
947f555
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,6 +146,10 @@ Generate a line-by-line heatmap:: | |
|
|
||
| python -m profiling.sampling run --heatmap script.py | ||
|
|
||
| Enable opcode-level profiling to see which bytecode instructions are executing:: | ||
|
|
||
| python -m profiling.sampling run --opcodes --flamegraph script.py | ||
|
|
||
|
|
||
| Commands | ||
| ======== | ||
|
|
@@ -379,6 +383,44 @@ see substantial time in ``<GC>`` frames, consider investigating object | |
| allocation rates or using object pooling. | ||
|
|
||
|
|
||
| Opcode-aware profiling | ||
| ---------------------- | ||
|
|
||
| The ``--opcodes`` option enables instruction-level profiling that captures | ||
| which Python bytecode instructions are executing at each sample:: | ||
|
|
||
| python -m profiling.sampling run --opcodes --flamegraph script.py | ||
|
|
||
| This feature provides visibility into Python's bytecode execution, including | ||
| adaptive specialization optimizations. When a generic instruction like | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering if it's worth linking back to https://docs.python.org/3/whatsnew/3.11.html#whatsnew311-pep659, in case people want to learn more about the specializing adaptive interpreter? |
||
| ``LOAD_ATTR`` is specialized at runtime into a more efficient variant like | ||
| ``LOAD_ATTR_INSTANCE_VALUE``, the profiler shows both the specialized name | ||
| and the base instruction. | ||
|
|
||
| Opcode information appears in several output formats: | ||
|
|
||
| - **Live mode**: An opcode panel shows instruction-level statistics for the | ||
| selected function, accessible via keyboard navigation | ||
| - **Flame graphs**: Nodes display opcode information when available, helping | ||
| identify which instructions consume the most time | ||
| - **Heatmap**: Expandable bytecode panels per source line show instruction | ||
| breakdown with specialization percentages | ||
| - **Gecko format**: Opcode transitions are emitted as interval markers in the | ||
| Firefox Profiler timeline | ||
|
|
||
| This level of detail is particularly useful for: | ||
|
|
||
| - Understanding the performance impact of Python's adaptive specialization | ||
| - Identifying hot bytecode instructions that might benefit from optimization | ||
| - Analyzing the effectiveness of different code patterns at the instruction level | ||
| - Debugging performance issues that occur at the bytecode level | ||
|
|
||
| The ``--opcodes`` option is compatible with ``--live``, ``--flamegraph``, | ||
| ``--heatmap``, and ``--gecko`` formats. It requires additional memory to store | ||
| opcode information and may slightly reduce sampling performance, but provides | ||
| unprecedented visibility into Python's execution model. | ||
|
|
||
|
|
||
| Real-time statistics | ||
| -------------------- | ||
|
|
||
|
|
@@ -760,6 +802,11 @@ and thread status statistics (GIL held percentage, CPU usage, GC time). The | |
| main table shows function statistics with the currently sorted column indicated | ||
| by an arrow (▼). | ||
|
|
||
| When ``--opcodes`` is enabled, an additional opcode panel appears below the | ||
| main table, showing instruction-level statistics for the currently selected | ||
| function. This panel displays which bytecode instructions are executing most | ||
| frequently, including specialized variants and their base opcodes. | ||
|
|
||
|
|
||
| Keyboard commands | ||
| ----------------- | ||
|
|
@@ -813,6 +860,11 @@ Within live mode, keyboard commands control the display: | |
| :kbd:`h` or :kbd:`?` | ||
| Show the help screen with all available commands. | ||
|
|
||
| :kbd:`j` / :kbd:`k` | ||
pablogsal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Navigate through opcode entries in the opcode panel (when ``--opcodes`` is | ||
| enabled). These keys scroll through the instruction-level statistics for the | ||
| currently selected function. | ||
|
|
||
| When profiling finishes (duration expires or target process exits), the display | ||
| shows a "PROFILING COMPLETE" banner and freezes the final results. You can | ||
| still navigate, sort, and filter the results before pressing :kbd:`q` to exit. | ||
|
|
@@ -939,6 +991,13 @@ Sampling options | |
|
|
||
| Enable async-aware profiling for asyncio programs. | ||
|
|
||
| .. option:: --opcodes | ||
|
|
||
| Gather bytecode opcode information for instruction-level profiling. Shows | ||
| which bytecode instructions are executing, including specializations. | ||
| Compatible with ``--live``, ``--flamegraph``, ``--heatmap``, and ``--gecko`` | ||
| formats only. | ||
|
|
||
|
|
||
| Mode options | ||
| ------------ | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.