gh-149296: Add dump subcommand to sampling profiler for one-shot stack snapshots#149297
Open
pablogsal wants to merge 1 commit intopython:mainfrom
Open
gh-149296: Add dump subcommand to sampling profiler for one-shot stack snapshots#149297pablogsal wants to merge 1 commit intopython:mainfrom
dump subcommand to sampling profiler for one-shot stack snapshots#149297pablogsal wants to merge 1 commit intopython:mainfrom
Conversation
dump subcommand to sampling profiler for one-shot st…dump subcommand to sampling profiler for one-shot stack snapshots
Documentation build overview
9 files changed ·
|
…hot stack snapshots Adds `python -m profiling.sampling dump <pid>`, which prints a single traceback-style snapshot of a running process's Python stack via the existing `_remote_debugging` unwinder. Supports per-thread status, source line highlighting, optional bytecode opcodes, and async-aware task reconstruction (`--async-aware`, default `--async-mode=all`).
ivonastojanovic
approved these changes
May 3, 2026
Contributor
ivonastojanovic
left a comment
There was a problem hiding this comment.
Nice, this looks great! Just a couple of small nits
| interpreter_id, | ||
| getattr(thread_info, "thread_id", None), | ||
| getattr(thread_info, "status", None), | ||
| frames or [], |
Contributor
There was a problem hiding this comment.
nit: Redundant?
Suggested change
| frames or [], | |
| frames, |
Comment on lines
+252
to
+255
| line for each frame and highlights the executing expression. If a source | ||
| file's modification time is newer than the target process's start time, | ||
| ``dump`` replaces the line with ``[source file changed after process | ||
| started]`` to avoid showing misleading code. |
Contributor
There was a problem hiding this comment.
We return None for non-Linux platforms in _target_process_start_time, so the [source file changed after process started] warning is never shown on macOS/Windows, should the docs mention this?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
python -m profiling.sampling dump <pid>, which prints a single traceback-style snapshot of a running process's Python stack via the existing_remote_debuggingunwinder. Supports per-thread status, source line highlighting, optional bytecode opcodes, and async-aware task reconstruction (--async-aware, default--async-mode=all).dumpsubcommand topython -m profiling.samplingfor one-shot stack snapshots #149296