GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-140727: Restructure profiling documentation for PEP 799 by pablogsal · Pull Request #142373 · python/cpython

Conversation

@pablogsal

@pablogsal pablogsal commented Dec 7, 2025 •
edited by hugovk
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This PR restructures the profiling documentation to match the new profiling
package introduced by PEP 799.

The existing monolithic profile.rst is split into focused pages:

  • profiling.rst: Entry point that helps users choose between statistical
    and deterministic profiling, with a comparison table and guidance on when to
    use each approach.

  • profiling-tracing.rst: Documents the deterministic profiler (formerly
    documented under cProfile). Notes that cProfile remains as a
    backward-compatible alias.

  • profiling-sampling.rst: Documents the new statistical sampling
    profiler. Includes quick examples upfront, explains the key concepts, covers
    all output formats (pstats, flamegraph, gecko, heatmap), live mode, and
    async-aware profiling. A defaults table shows what happens without any flags.

  • pstats.rst: Separated out since it's used by both profiler types.

  • profile.rst: Reduced to a deprecation stub with migration guidance for
    users of the pure Python profiler.

The whatsnew entry is updated to link to the new documentation and reference
profiling.tracing instead of cProfile.

  • Issue: Document new profiling package and restructure the profiler docs according to PEP 799 #140727

📚 Documentation preview 📚: https://cpython-previews--142373.org.readthedocs.build/en/142373/library/profiling.html

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gpshead reacted with heart emoji gpshead reacted with rocket emoji
All reactions
  • ❤️ 1 reaction
  • 🚀 1 reaction
pablogsal added 6 commits December 7, 2025 03:52
@pablogsal
Add profiling module documentation structure
ff62d3d
PEP 799 introduces a new `profiling` package that reorganizes Python's
profiling tools under a unified namespace. This commit adds the documentation
structure to match: a main entry point (profiling.rst) that helps users choose
between profilers, detailed docs for the tracing profiler (profiling-tracing.rst),
and separated pstats documentation.

The tracing profiler docs note that cProfile remains as a backward-compatible
alias, so existing code continues to work. The pstats module gets its own page
since it's used by both profiler types and deserves focused documentation.
@pablogsal
Add profiling.sampling documentation
1c712f1
The sampling profiler is new in Python 3.15 and works fundamentally differently
from the tracing profiler. It observes programs from outside by periodically
capturing stack snapshots, which means zero overhead on the profiled code. This
makes it practical for production use where you can attach to live servers.

The docs explain the key concepts (statistical vs deterministic profiling),
provide quick examples upfront, document all output formats (pstats, flamegraph,
gecko, heatmap), and cover the live TUI mode. The defaults table helps users
understand what happens without any flags.
@pablogsal
Wire profiling docs into the documentation tree
d34d17b
Add the new profiling module pages to the Debugging and Profiling toctree.
The order places the main profiling.rst entry point first, followed by the
two profiler implementations, then pstats, and finally the deprecated profile
module last.
@pablogsal
Convert profile.rst to deprecation stub
9da3576
The pure Python profile module is deprecated in 3.15 and scheduled for removal
in 3.17. Users should migrate to profiling.tracing (or use the cProfile alias
which continues to work).

The page now focuses on helping existing users migrate: it shows the old vs new
import style, keeps the shared API reference since both modules have the same
interface, and preserves the calibration docs for anyone still using the pure
Python implementation during the transition period.
@pablogsal
Update CLI module references for profiling restructure
75413e4
Point cProfile to profiling.tracing docs and add profiling.sampling to the
list of modules with CLI interfaces. The old profile-cli label no longer
exists after the documentation restructure.
@pablogsal
Update whatsnew to link to profiling module docs
1bcb081
Enable cross-references to the new profiling module documentation and update
the CLI examples to use the current syntax with the attach subcommand. Also
reference profiling.tracing instead of cProfile since that's the new canonical
name.
@pablogsal
pablogsal requested a review from AA-Turner as a code owner December 7, 2025 03:53
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Dec 7, 2025
@github-project-automation github-project-automation Bot added this to Docs PRs Dec 7, 2025
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Dec 7, 2025
@bedevere-app bedevere-app Bot added the awaiting core review label Dec 7, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Dec 7, 2025
Document new profiling package and restructure the profiler docs according to PEP 799 #140727
Closed
@pablogsal
pablogsal requested a review from hugovk December 7, 2025 03:53
@pablogsal

pablogsal commented Dec 7, 2025

Copy link
Copy Markdown
Member Author

Most of this PR is moving existing documentation into separate files rather than writing new content. The profiling-tracing.rst and pstats.rst pages are largely relocated from the old profile.rst, and profile.rst itself is reduced to a deprecation stub with migration guidance.

The actual new writing is in profiling-sampling.rst, which documents the new statistical sampling profiler. This is where review attention is most valuable. The profiling.rst entry point also has new prose explaining when to use each profiler type.

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal added 3 commits December 7, 2025 03:59
@pablogsal
Fix warnings
ca3fed7
@pablogsal
Fix warnings
c1523bf
@pablogsal
Fix warnings
e8c5aca
StanFromIreland
StanFromIreland reviewed Dec 7, 2025
View reviewed changes
Comment thread Doc/library/profiling-tracing.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/profiling-sampling.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/profiling-sampling.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/profiling-sampling.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/profiling-sampling.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/profile.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/profile.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

pablogsal and others added 4 commits December 7, 2025 18:25
@pablogsal @StanFromIreland
Apply suggestions from code review
f0f9dec
Co-authored-by: Stan Ulbrych <[email protected]>
@pablogsal @StanFromIreland
Update Doc/library/profile.rst
8c07f22
Co-authored-by: Stan Ulbrych <[email protected]>
@pablogsal
Small improvements and address feedback
ba35cd0
@pablogsal
Add tachyon (provisional) logo
4ef946a
gpshead
gpshead reviewed Dec 7, 2025
View reviewed changes
Comment thread Doc/library/profiling.sampling.rst
:mod:`threading` module or implicitly through libraries that manage thread
pools.

By default, the profiler samples only the main thread. The ``--all-threads``

@gpshead gpshead Dec 7, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Threading feels quite common. It feels like the option even existing implies there is some consequence of enabling it? State why someone might NOT want to sample all threads in the docs.

Perhaps out of scope for this docs PR, but do we actually want this default or should it be the opposite? Does the option then even need to exist?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@pablogsal pablogsal Dec 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Threading feels quite common. It feels like the option even existing implies there is some consequence of enabling it? State why someone might NOT want to sample all threads in the docs.
Perhaps out of scope for this docs PR, but do we actually want this default or should it be the opposite? Does the option then even need to exist?

We can discuss this elsewhere, but the reason is that is more expensive. You are basically dividing the sampling rate by the number of threads. There are also some of important optimizations if you know that you only want to sample the main thread.

This also generates a lot more data so the result files are a bit bigger. We can chat about what we think the default should be but the option should exist so people can decide to dedicate all sampling budget to the main thread if they wish. This can make a big difference.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@pablogsal pablogsal Dec 7, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State why someone might NOT want to sample all threads in the docs.

Good point 👍 Will do

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pablogsal

pablogsal commented Dec 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Tachyon logo by @maigimenez ❤️ (she did the 3.11 and 3.10 cool release logos)

savannahostrowski, gpshead, and hugovk reacted with heart emoji
All reactions
  • ❤️ 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

savannahostrowski
savannahostrowski reviewed Dec 7, 2025
View reviewed changes
Comment thread Doc/library/profiling-sampling.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

gpshead
gpshead reviewed Dec 7, 2025
View reviewed changes
Comment thread Doc/library/pstats.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/tachyon-logo.png Resolved

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland
StanFromIreland reviewed Dec 7, 2025
View reviewed changes
Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

pablogsal and others added 2 commits December 7, 2025 21:23
@pablogsal @StanFromIreland
Update Doc/whatsnew/3.15.rst
eaa05bf
Co-authored-by: Stan Ulbrych <[email protected]>
@StanFromIreland
find . -name '*.png' | xargs optipng -o7
e614a80
@hugovk hugovk mentioned this pull request Dec 8, 2025
Review comments for "Restructure profiling documentation for PEP 799" pablogsal/cpython#108
Merged
hugovk
hugovk reviewed Dec 8, 2025
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started adding suggestions via the GitHub UI but it was taking 4s to click the + and 6s to click "Add review comment" so I gave up and opened pablogsal#108 instead :/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Comment thread Doc/library/debug.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/profiling.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal
Merge pull request #108 from hugovk/3.15-gh-140727
d7376db
@pablogsal

pablogsal commented Dec 8, 2025

Copy link
Copy Markdown
Member Author

I started adding suggestions via the GitHub UI but it was taking 4s to click the + and 6s to click "Add review comment" so I gave up and opened pablogsal#108 instead :/

giphy

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal and others added 2 commits December 8, 2025 15:01
@pablogsal @hugovk
Update Doc/library/profiling.rst
3bfa0ec
Co-authored-by: Hugo van Kemenade <[email protected]>
@pablogsal
Fixes
8200ba7
@pablogsal
pablogsal requested review from gpshead, hugovk and savannahostrowski December 8, 2025 15:03
pablogsal and others added 5 commits December 8, 2025 15:08
@pablogsal
Add cross link
2c2fd93
@pablogsal
Improve sampling docs
ef985de
@pablogsal
better logo
e7bd8b1
@pablogsal
Merge branch 'main' into pythongh-140727
fda1b16
@hugovk
oxipng -o max --strip all (13.13% smaller)
61d12a5
@hugovk hugovk mentioned this pull request Dec 9, 2025
Optimise images pablogsal/cpython#111
Merged
hugovk added 2 commits December 9, 2025 11:42
@hugovk
Restructure dashes to dots
8fb311b
@hugovk
Use script.py like in other profiling docs
f766a5a
@hugovk hugovk mentioned this pull request Dec 9, 2025
Restructure dashes to dots pablogsal/cpython#112
Merged
hugovk and others added 3 commits December 9, 2025 11:55
@hugovk
Sentence case headings
d667578
@pablogsal
Merge pull request #111 from hugovk/3.15-gh-140727
c697764
@pablogsal
Merge pull request #112 from hugovk/3.15-gh-140727-dashes-to-dots
499e69e
hugovk
hugovk approved these changes Dec 9, 2025
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Dec 9, 2025
@pablogsal
pablogsal merged commit 4279785 into python:main Dec 9, 2025
50 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal
pablogsal deleted the gh-140727 branch December 9, 2025 12:55
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Dec 9, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 9, 2025
@pablogsal

pablogsal commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

Thanks everyone for the review! ❤️

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielNoord DanielNoord mentioned this pull request Feb 8, 2026
bpo-18795: Add cumpercall and totalpercall keys to pstats sort_stats #31919
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@StanFromIreland StanFromIreland StanFromIreland left review comments
@hugovk hugovk hugovk approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@gpshead gpshead Awaiting requested review from gpshead
@savannahostrowski savannahostrowski Awaiting requested review from savannahostrowski

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@pablogsal @gpshead @hugovk @savannahostrowski @StanFromIreland
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.