121 Commits
Author SHA1 Message Date
Pablo Galindo Salgado 114de198c0 gh-156545, gh-158539: Fix deep flamegraph export on small C stacks and macOS runtime lookup (#158874) 2026-10-05 20:56:24 +01:00
Pablo Galindo Salgado 64bad23540 gh-154062: Stop normalizing differential flamegraph duration (#154082)
* gh-154062: Stop normalizing differential flamegraph duration

* gh-154032: Scale elided flamegraph values

* gh-154062: Keep elided metadata in raw sample units
2026-10-05 17:56:52 +01:00
tonghuaroot (童话)andPablo Galindo Salgado 722687092f gh-153838: Skip non-regular source files in the heatmap exporter (#153839)
* gh-153838: Skip non-regular and oversized files in heatmap exporter

* Drop the size cap, keep the is_file() guard only

* gh-153838: Verify non-regular sources are never opened

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-10-05 15:50:03 +01:00
tonghuaroot (童话)andPablo Galindo Salgado 1441e51dbc gh-156545: Fix flamegraph export RecursionError on deeply recursive programs (#156546)
* gh-156545: Fix flamegraph export RecursionError on deeply recursive programs

* Tighten comments

* gh-156545: Verify recursion limit restoration during export

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-10-05 15:37:06 +01:00
he_taoandEduardo Villalpando Mello 3f02aab9fa gh-158540: Add the profiled script's directory to sys.path (#158548)
* gh-158540: Add the profiled script's directory to sys.path

When a script is profiled with ``python -m profiling.sampling run
script.py`` from another directory, the script cannot import modules
placed next to it, because ``_sync_coordinator._execute_script()``
executes it with the working directory (added by
``_setup_environment()`` for the module case) as ``sys.path[0]``
instead of the script's own directory.

Make the script's directory importable in ``_execute_script()``,
matching the behavior of ``python script.py``.

Add a regression test that runs the coordinator on a script importing
a sibling module.

* Update _sync_coordinator.py Comment simplified

Co-authored-by: Eduardo Villalpando Mello <eduardo.villalpando.mello@gmail.com>

* gh-158540: Resolve symlinks when adding the script directory to sys.path

``python script.py`` resolves symlinks when computing ``sys.path[0]``, so
a script reached through a symlink (``link.py -> sub/where.py``) imports
modules from the real script's directory.  Apply ``os.path.realpath()``
before taking the directory name, and make sure the result is placed at
the front of ``sys.path`` even if it was already listed.

Add a regression test for a symlinked script.

---------

Co-authored-by: Eduardo Villalpando Mello <eduardo.villalpando.mello@gmail.com>
2026-10-05 14:51:20 +01:00
Maurycy Pawłowski-WierońskiandPablo Galindo Salgado f839c061d3 gh-151292: _remote_debugging: Do not corrupt the binary file when hitting OverflowError (#152892)
* the kolektor

* test

* better test

* news

* =Q, move const to the base, not self.running

* gh-151292: Track binary writer finalization state

---------

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-10-05 01:04:20 +00:00
Pablo Galindo Salgado d3663ef943 gh-154090: Store profiling mode and capture settings in binary profiles (GH-154105) 2026-09-24 23:17:30 +00:00
Peter FackeldeyandPablo Galindo Salgado 0546b5f393 gh-154335: Allow disabling terminal colors in Tachyon's pstats_collector module (#154344)
* Use _colorize.get_colors() to allow disabling ANSI escape codes through environment variables

* add news entry

* use get_colors() instead of ANSIColors enum also in Lib/profiling/sampling/sample.py

* fix data_lines collection of pstats lines for no-color mode

* preserve lazy import of _colorize

* gh-154335: Cover profiler color policy and update NEWS

---------

Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2026-09-24 17:48:46 +01:00
tonghuaroot (童话) c3706f4c68 gh-156810: Write the profiler's collapsed-stack export as UTF-8 (#156811) 2026-09-02 10:01:29 +00:00
Pablo Galindo Salgado 7f0ccd6c0e gh-154060: Preserve replay duration and rate (#154101) 2026-08-26 10:24:00 +01:00
Pablo Galindo Salgado cf7e9108bd gh-154089: Hide unavailable replay efficiency (#154092) 2026-08-25 23:33:18 +01:00
Pablo Galindo Salgado b22d175c05 gh-154088: Count elided stacks consistently (#154093) 2026-08-25 23:32:34 +01:00
Pablo Galindo Salgado 53381bcd74 gh-154085: Avoid duplicating diff line values (#154099) 2026-08-25 23:32:21 +01:00
Pablo Galindo Salgado ee68f5f46a gh-154059: Fix Tachyon flame graph time units (#154036) 2026-08-11 23:16:05 +00:00
Pablo Galindo Salgado e4b22adf24 gh-154086: Fix flamegraph thread sample counts (#154104) 2026-08-10 16:40:08 +01:00
Stan Ulbrych f40b375ec6 Bump profiling.sampling.cli._SYNC_TIMEOUT_SEC to fix failures on slow Buildbots (#154248) 2026-07-20 12:14:45 +02:00
Łukasz 43b0e01b50 gh-153293: Clear opcode statistics in the live profiler's reset_stats() (#153295) 2026-07-11 18:44:31 +01:00
DupratandPablo Galindo Salgado d7275d3569 gh-140729: Fix the cProfile module when the executed script contains calls to multiprocessing.Process (#144715)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2026-07-07 00:39:06 +01:00
László Kiss Kollár 87ac0bc66a gh-152434: Fix async-aware Gecko collection (#152442) 2026-06-27 17:29:50 +00:00
ivonastojanovic 860f8a5add gh-145306: Fix browser open after empty export (#150017) 2026-06-27 19:09:49 +02:00
László Kiss Kollár 876c06cab9 gh-152434: Block --async-aware with --binary (#152444)
The binary writer does not currently handle AwaitedInfo samples and
crashes when running in --async-aware mode.
2026-06-27 16:55:57 +00:00
Hugo van Kemenade 627adb517f gh-151428: Remove unused imports from stdlib (#151478) 2026-06-16 19:31:01 +03:00
Eduardo Villalpando Mello 5c13217314 gh-148932: Fix profiling.sampling on Windows virtual environments (#150541) 2026-06-08 17:25:43 +00:00
Maurycy Pawłowski-Wieroński 785b6dcf71 gh-150662: Stop unbounded memory growth in Tachyon --gecko collector (#150845) 2026-06-06 02:27:41 +00:00
Eduardo Villalpando Mello fad0674605 gh-150258: Show relative percentage on Tachyon flamegraph (#150266)
When running profiling, users rarely care about the global percentage of
the runtime. Often, they want to select a function and measure child
percentages relative to that.

This PR updates the flamegraph tooltips to show both "Percentage" and
"Relative Percentage" when the user clicks a specific function.
2026-05-23 08:31:26 -04:00
Pablo Galindo Salgado 661df25692 gh-149584: Fix excessive overhead in the Tachyon profiler regarding the cache behavior (#149649)
Use exact remote reads for interpreter state, thread state, and
interpreter frame structs instead of pulling full remote pages into the
profiler page cache. This matches the core change from
python/cpython#149585.

The profiler clears the page cache between samples, so live entries are
always packed at the front. Track the live count and only clear/search
that prefix instead of scanning all 1024 slots on the hot path.

Use the frame cache to predict the next thread state and top frame
address, then batch interpreter/thread/frame reads with process_vm_readv
when profiling a Linux target. Reuse prefetched frame buffers in the
frame walker when the prediction is valid.

Cache the last FrameInfo tuple per code object/instruction offset, reuse
cached thread id objects, and append cached parent frames directly on
full frame-cache hits. This cuts Python allocation churn in the
steady-state profiler path.
2026-05-20 04:32:08 -07:00
László Kiss Kollár 06a2830aa8 gh-150034: Print JSONL filename when profiling finishes (#150035) 2026-05-20 04:29:48 -07:00
Maurycy Pawłowski-Wieroński 76f2285341 gh-149718: Aggregate same stack frames in Tachyon in some collectors (#149719) 2026-05-12 23:46:21 +00:00
László Kiss Kollár 9587726a3e gh-149430: Fix edge-cases in profiling.sampling outputs (#149431)
The line highlights on the heatmap are driven by the URL hash and the
`:target` selector. When clicking a caller/callee link for the line that
was already selected, the hash doesn't change, so the browser keeps the
existing target state and doesn't restart the animation. Due to this the
highlight only works the first time.

With this fix, line navigation goes through JavaScript. If the target
URL already points to the current location, the highlight is replayed by
clearing the animation, forcing style recalculation, and restoring it.

The `baseline_self` variable isn't initialized for structural elided
roots. This variable is accessed later unconditionally and leads to a
crash.

The child process ends up being invoked with `--diff_flamegraph` instead
of the correct argument.
2026-05-09 14:05:46 +01:00
Hugo van Kemenade 7cea70e14d gh-144384: Lazily import _colorize (#149318) 2026-05-06 16:07:43 +00:00
Maurycy Pawłowski-Wieroński 04ce318522 gh-146256: Add --jsonl collector to the profiling.sampling (#146257) 2026-05-05 00:44:37 +00:00
Hugo van KemenadeandSavannah Ostrowski ef6f0635ce gh-142389: Add backticks to stdlib argparse help to display in colour (#149384)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2026-05-04 22:23:18 +00:00
Pablo Galindo Salgado 3efd2f4db6 gh-149296: Add dump subcommand to sampling profiler for one-shot stack snapshots (#149297)
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`).
2026-05-04 01:02:33 +01:00
Sergey Miryanov fea2a57282 GH-148932: Improve error message if profiling.sampling run from venv on Windows platform (#149247) 2026-05-02 09:23:16 +00:00
ivonastojanovic d4eee16659 gh-142927: Show module names instead of file paths in flamegraph (#146040) 2026-04-29 10:00:07 +01:00
ivonastojanovic 993e204ad4 gh-142927: Fix inverted flamegraph width (#148568)
Fix inverted flamegraph width

The inverted view used thread presence as a proxy for self time.
This missed self samples on C-level wrapper frames like _run_code,
where the node's thread always appears in its children too. Those
samples were silently dropped, causing the chart to render narrower
than full width. Now uses the explicit self field on each node
instead of the thread heuristic.
2026-04-28 17:42:21 +01:00
Mai Giménez a2fa63b787 gh-140727: Update tachyon logo (#148965) 2026-04-25 22:27:11 +01:00
Pablo Galindo Salgado efde4333bf gh-148225: Validate profiling.sampling replay input (#148243) 2026-04-08 23:34:46 +00:00
ivonastojanovic 4ff8b07a3d gh-142927: Show self time in flamegraph tooltip (#147706)
We already show self time in differential flamegraphs, but it should
be included in regular flamegraphs as well. Display the time spent
in the function body excluding callees, not just the total inclusive
time.
2026-04-04 20:55:05 +01:00
Thomas Kowalski b4fac15613 gh-145458: use self.skip_idle consistently in the tachyon profiler (#145459) 2026-03-31 09:57:07 +01:00
ivonastojanovicandPablo Galindo Salgado f4d3c61f36 gh-138122: Add differential flame graph (#145785)
Differential flame graphs compare two profiling runs and highlight where
performance has changed. This makes it easier to detect regressions
introduced by code changes and to verify that optimizations have the
intended effect.

The visualization renders the current profile with frame widths
representing current time consumption. Color is then applied to show the
difference relative to the baseline profile: red gradients indicate
regressions, while blue gradients indicate improvements.

Some call paths may disappear entirely between profiles. These are
referred to as elided stacks and occur when optimizations remove code
paths or when certain branches stop executing. When elided stacks are
present, an "Elided" toggle is displayed, allowing the user to switch
between the main differential view and a view showing only the removed
paths.

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2026-03-30 12:31:06 +01:00
flow a17301ab3d gh-135953: Properly obtain main thread identifier in Gecko Collector (#146045) 2026-03-22 18:53:00 +00:00
Hugo van Kemenade 104cae039a gh-142927: Move hotspots up flamegraph sidebar (#145428) 2026-03-16 23:01:41 +00:00
Hugo van Kemenade 368a26777a gh-142927: Detect system theme in flame graph like in heatmap (#144885) 2026-03-10 13:38:48 +02:00
Hugo van Kemenade 2e2109d224 gh-142927: Tachyon: Fix singular and plurals (#145329) 2026-02-28 01:48:35 +00:00
Maurycy Pawłowski-Wieroński be4ee8ee42 gh-144342: Use time.sleep in profiling.sampling (#144343) 2026-01-30 15:13:21 +00:00
Divyanshu Choudhury 5f57f6970b gh-143423: Fix free-threaded build detection in sampling profiler (#143426) 2026-01-30 00:35:30 +00:00
László Kiss Kollár ef3b8829e4 gh-142927: Clarify pstats file output in docs and CLI (#143388)
When running the `profiling.sampling` module in pstats mode, the output
can be emitted in two different ways: text to stdout or a binary file
when the `--output` argument is set.

The current documentation and help text is confusing as it does not
distinguish between these two output formats so it may be surprising to
the user to get different formats depending whether `--output` is set or not.
2026-01-03 21:16:29 +00:00
Pablo Galindo Salgado 09ce592499 gh-142927: Hide _sync_coordinator frames from profiler output (#143337) 2026-01-02 12:09:36 +00:00
Pablo Galindo Salgado 6b9a6c6ec3 gh-138122: Move local imports to module level in sampling profiler (#143257) 2026-01-02 02:31:39 +00:00