Skip to content

Modernise profiler internals and CI - #454

Merged
joerick merged 14 commits into
mainfrom
modernise
Jul 29, 2026
Merged

Modernise profiler internals and CI#454
joerick merged 14 commits into
mainfrom
modernise

Conversation

@joerick

@joerick joerick commented Jul 29, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

  • harden native profiler and sampler lifecycle error handling
  • handle unset profiler context variables consistently
  • preserve qualified class names in native frames
  • improve asynchronous IPython compatibility and cleanup
  • add Python 3.14 CI coverage and fix the wheel matrix
  • replace Black and isort with Ruff, with a Nox lint session

Draft for CI validation.

AI assistance: Amp was used to help develop and test these changes.

joerick added 12 commits July 29, 2026 18:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes and hardens pyinstrument’s profiling internals (Python + native), expands test coverage around edge cases (contextvars, frame metadata, IPython async), and updates the project’s formatting/linting + CI matrices (including Python 3.14).

Changes:

  • Harden stack sampler / native profiler lifecycle handling (rollback on failure, safer contextvar reads, tighter native error handling).
  • Preserve qualified class names in native frame identifiers and add regression tests for “no locals” and nested classes.
  • Modernize tooling/CI: move import sorting/formatting to Ruff + add Nox lint session + expand CI/test/wheel matrices (incl. 3.14 and ARM runners).

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/test_threading.py Reorders imports to match new lint/format tooling.
test/test_stack_sampler.py Adds regression test ensuring failed subscribe rolls back sampler state.
test/test_pstats_renderer.py Reorders imports to match new lint/format tooling.
test/test_profiler.py Adds session root-frame regression test and minor assertion formatting changes.
test/test_profiler_async.py Reorders imports to match new lint/format tooling.
test/test_processors.py Reorders imports to match new lint/format tooling.
test/test_ipython_magic.py Adds async/IPython cleanup tests and warning filtering; imports asyncio.
test/test_context_manager.py Reorders imports to match new lint/format tooling.
test/low_level/test_frame_info.py Adds tests for nested qualified class names and frames with no locals.
test/low_level/test_custom_timer.py Adds regression test ensuring invalid timer return values don’t leak references.
test/low_level/test_context.py Adds coverage for contextvars without defaults in low-level profiler.
pyproject.toml Introduces Ruff configuration (line length/target/excludes/import sorting).
pyinstrument/stack_sampler.py Adds rollback logic in subscribe() to restore state on failures.
pyinstrument/session.py Fixes trimming logic when start call stack is empty.
pyinstrument/magic/magic.py Refactors run_cell_async to improve IPython async compatibility and cleanup.
pyinstrument/low_level/stat_profile.c Improves contextvar handling, refcounting on errors, qualified class name extraction, and error paths.
pyinstrument/low_level/stat_profile_python.py Aligns contextvar .get(None) behavior with native implementation.
pyinstrument/frame.py Minor assertion formatting change.
noxfile.py Adds a lint session using prek; expands test session to Python 3.14.
metrics/overhead.py Formatting-only change (string quoting in f-string).
.pre-commit-config.yaml Replaces isort/Black hooks with Ruff check + Ruff format.
.github/workflows/wheels.yml Updates wheel build matrix to include ARM runner and removes QEMU setup.
.github/workflows/test.yml Expands test matrix to Python 3.14 (incl. ARM).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyinstrument/stack_sampler.py
Comment thread pyinstrument/magic/magic.py
Comment thread pyinstrument/low_level/stat_profile.c
@joerick
joerick marked this pull request as ready for review July 29, 2026 19:41
@joerick
joerick merged commit 418f6a2 into main Jul 29, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants