Repository navigation
Add tracing profiler and Python 3.15 offline profiling tools #9271
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
Merged
youknowone
merged 13 commits into
RustPython:main
from
youknowdot:split/profiler-consumer-315
Oct 22, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e0fb08a
Add deterministic profiler and canonical Python 3.15 tools
youknowdot 869cb1a
Clarify standalone profiling license cross-reference
youknowdot 78b21a2
Defer unsupported sampling package from profiler extraction
youknowdot 52f2359
Stage profiling root as a namespace until sampling is available
youknowdot 94f8b2b
Match canonical static builtin profiler labels and metadata
youknowdot d5a8049
Support collision-safe frozen package containers
youknowdot 09cb704
Revert frozen package containers before restoring canonical profiling…
youknowdot 7e3b98e
Restore canonical profiling package with offline sampling codec
youknowdot e8f0bcf
Keep platform-dependent C long normalization explicit
youknowdot 69e4738
Include profiling notices in library and desktop packages
youknowdot eab90b8
Keep profiling asset license notice in pylib crate
youknowdot 1200603
Serve frozen profiling assets through native resource readers
youknowdot cc49b37
Preserve canonical profiling asset line endings on checkout
youknowdot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """Compatibility wrapper for cProfile module. | ||
| This module maintains backward compatibility by importing from the new | ||
| profiling.tracing module. | ||
| """ | ||
|
|
||
| from profiling.tracing import run, runctx, Profile | ||
|
|
||
| __all__ = ["run", "runctx", "Profile"] | ||
|
|
||
| if __name__ == "__main__": | ||
| from profiling.tracing.__main__ import main | ||
| main() | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """Python profiling tools. | ||
| This package provides two types of profilers: | ||
| - profiling.tracing: Deterministic tracing profiler that instruments every | ||
| function call and return. Higher overhead but provides exact call counts | ||
| and timing. | ||
| - profiling.sampling: Statistical sampling profiler that periodically samples | ||
| the call stack. Low overhead and suitable for production use. | ||
| """ | ||
|
|
||
| __all__ = ("tracing", "sampling") |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| """Statistical sampling profiler for Python. | ||
| This module provides low-overhead profiling by periodically sampling the | ||
| call stack rather than tracing every function call. | ||
| """ | ||
|
|
||
| from .collector import Collector | ||
| from .pstats_collector import PstatsCollector | ||
| from .stack_collector import CollapsedStackCollector | ||
| from .heatmap_collector import HeatmapCollector | ||
| from .gecko_collector import GeckoCollector | ||
| from .jsonl_collector import JsonlCollector | ||
| from .string_table import StringTable | ||
|
|
||
| __all__ = ( | ||
| "Collector", | ||
| "PstatsCollector", | ||
| "CollapsedStackCollector", | ||
| "HeatmapCollector", | ||
| "GeckoCollector", | ||
| "JsonlCollector", | ||
| "StringTable", | ||
| ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import importlib.resources | ||
|
|
||
|
|
||
| def get_combined_css(component: str) -> str: | ||
| template_dir = importlib.resources.files(__package__) | ||
|
|
||
| base_css = (template_dir / "_shared_assets" / "base.css").read_text(encoding="utf-8") | ||
|
|
||
| if component == "flamegraph": | ||
| component_css = ( | ||
| template_dir / "_flamegraph_assets" / "flamegraph.css" | ||
| ).read_text(encoding="utf-8") | ||
| elif component == "heatmap": | ||
| component_css = (template_dir / "_heatmap_assets" / "heatmap.css").read_text( | ||
| encoding="utf-8" | ||
| ) | ||
| else: | ||
| raise ValueError( | ||
| f"Unknown component: {component}. Expected 'flamegraph' or 'heatmap'." | ||
| ) | ||
|
|
||
| return f"{base_css}\n\n{component_css}" |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
In the default WASM/
freeze-stdlibconfiguration,import cProfilereaches this import but cannot resolve its parent package: the freeze compiler only emits entries for.pyfiles and only marks__init__.pyentries as packages (crates/derive-impl/src/compile_bytecode.rs:172-235), while a repo-wide search finds noLib/profiling/__init__.pyand the frozen importer does exact-name lookups. The frozen map therefore containsprofiling.tracingbut noprofiling, so deployments without theLibfilesystem cannot use the newly added cProfile module; add a minimal parent package or synthesize a frozen namespace entry.AGENTS.md reference: AGENTS.md:L7-L11
Useful? React with 👍 / 👎.