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-138122: Add thread status statistics to flamegraph profiler by pablogsal · Pull Request #141900 · python/cpython

Conversation

@pablogsal

@pablogsal pablogsal commented Nov 24, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

The flamegraph profiler now collects thread state information (GIL held, GIL released, waiting for GIL, and garbage collection activity) during sampling and displays it in an interactive statistics bar. This helps users identify GIL contention and understand thread behavior patterns.

Statistics are calculated both in aggregate and per-thread. When filtering the flamegraph to a specific thread, the display updates to show that thread's metrics. In GIL-only profiling mode, GIL-related statistics are hidden since they aren't meaningful in that context.

Per-thread GC percentages now use total samples as the denominator instead of per-thread sample counts. This makes them directly comparable with aggregate statistics and easier to interpret when threads appear in different numbers of samples.

  • Issue: Implement PEP 799 – A dedicated profiling package for organizing Python profiling tools #138122

Sorry, something went wrong.

Uh oh!

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

dolfinus and ermakov-oleg reacted with rocket emoji
All reactions
  • 🚀 2 reactions
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 24, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Nov 24, 2025
Implement PEP 799 – A dedicated profiling package for organizing Python profiling tools #138122
Closed
@pablogsal pablogsal added skip news and removed skip news labels Nov 24, 2025
@pablogsal
pablogsal force-pushed the flamegraph-better branch from c226154 to 3e0224f Compare November 24, 2025 14:06
@pablogsal
pablogsal requested a review from Copilot November 24, 2025 14:07
Copilot started reviewing on behalf of pablogsal November 24, 2025 14:08
View session
@pablogsal
pablogsal force-pushed the flamegraph-better branch from 3e0224f to 21bbd24 Compare November 24, 2025 14:08
Copilot finished reviewing on behalf of pablogsal November 24, 2025 14:11
@pablogsal
pythongh-138122: Track and display thread status statistics in flameg…
9694d5a
…raph profiler

The flamegraph profiler now collects thread state information (GIL held,
GIL released, waiting for GIL, and garbage collection activity) during
sampling and displays it in an interactive statistics bar. This helps users
identify GIL contention and understand thread behavior patterns.

Statistics are calculated both in aggregate and per-thread. When filtering
the flamegraph to a specific thread, the display updates to show that
thread's metrics. In GIL-only profiling mode, GIL-related statistics are
hidden since they aren't meaningful in that context.

The collection logic was refactored to process each sample in a single pass
rather than iterating through threads multiple times. GC frame detection now
uses a shared helper that consistently handles both tuple and object frame
formats.

Per-thread GC percentages now use total samples as the denominator instead
of per-thread sample counts. This makes them directly comparable with
aggregate statistics and easier to interpret when threads appear in different
numbers of samples.

The JavaScript includes null checks for DOM access and validates data
availability before rendering. Tests verify the JSON structure, percentage
calculations, and edge cases like zero samples, using only public APIs.
@pablogsal
pablogsal force-pushed the flamegraph-better branch from 21bbd24 to 9694d5a Compare November 24, 2025 14:16

This comment was marked as off-topic.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

@pablogsal
pablogsal requested a review from ivonastojanovic November 24, 2025 20:38
@pablogsal

pablogsal commented Nov 24, 2025

Copy link
Copy Markdown
Member Author

CC @ivonastojanovic

All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal
fixup! pythongh-138122: Track and display thread status statistics in…
b928596
… flamegraph profiler
ivonastojanovic
ivonastojanovic reviewed Nov 29, 2025
View reviewed changes

@ivonastojanovic ivonastojanovic left a comment

Copy link
Copy Markdown
Contributor

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.

Looks good to me! One small thing: for the percentages in the thread-stats-bar, maybe we should use the same rounding as the flamegraph nodes so everything is consistent.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/profiling/sampling/flamegraph.js Resolved

Uh oh!

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

Comment thread Lib/profiling/sampling/flamegraph.js Resolved

Uh oh!

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

Comment thread Lib/profiling/sampling/flamegraph.js Resolved

Uh oh!

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

Comment thread Lib/profiling/sampling/flamegraph.js Resolved

Uh oh!

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

pablogsal and others added 2 commits November 30, 2025 01:04
@pablogsal @ivonastojanovic
Apply suggestions from code review
0873918
Co-authored-by: ivonastojanovic <[email protected]>
@pablogsal
fixup! Apply suggestions from code review
b70a62b
@pablogsal
pablogsal enabled auto-merge (squash) November 30, 2025 01:27
@pablogsal
pablogsal merged commit ea51e74 into python:main Nov 30, 2025
46 checks passed

Uh oh!

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

@pablogsal
pablogsal deleted the flamegraph-better branch November 30, 2025 01:42
@bedevere-app bedevere-app Bot removed the awaiting core review label Nov 30, 2025
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@pablogsal @ivonastojanovic @StanFromIreland
pythongh-138122: Add thread status statistics to flamegraph profiler (p…
3262f82
…ython#141900)

Co-authored-by: ivonastojanovic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ivonastojanovic ivonastojanovic ivonastojanovic left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@pablogsal @ivonastojanovic
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 01402503 — 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.