A stall tracker for Python's GIL and Trio tasks
Project description
Perpetuo
perpetuo, verb: To cause to continue uninterruptedly, to proceed with continually
Perpetuo is a stall tracker for Python. Specifically, it can detect when:
-
One thread is holding the GIL for too long, blocking other threads from having a chance to run (requires an instrumented version of CPython)
-
One Trio task is running too long without checkpointing, blocking other tasks from having a chance to run
The actual monitoring is done from a separate process, using a customized version of py-spy. So the monitoring is very low overhead and should not interfere with the monitored process at all. The goal is to be able to use this in production.
Quickstart
-
pip install perpetuo -
Optional: patch CPython (see below)
-
import perpetuo -
If you're using Trio: call
perpetuo.dwim()insidetrio.runIf you're not using Trio: call
perpetuo.dwim()anywhere -
Optional: log
perpetuo.dwim()'s return value to see what it did
Available API
perpetuo.start_watcher(): Spawns the monitoring process in the background.
perpetuo.instrument_gil(): Enables GIL instrumentation, or raises
RuntimeError if you don't have the patched version of CPython.
perpetuo.instrument_trio(): Enables Trio instrumentation. Must be called
inside trio.run.
perpetuo.dwim(): Attempts to call all the above functions as appropriate, and
returns a list of strings describing which operations it actually performed. If
you're using Trio, make sure to call it inside trio.run.
StallTracker: Low-level class that allows you to add custom instrumentation to
other things. See source for details.
Patching CPython to instrument the GIL
There are patches available for:
CPython version 3.10.*:
https://github.com/python/cpython/compare/3.10...njsmith:cpython:njs/perpetuo-gil.diff
CPython version 3.11:
https://github.com/python/cpython/compare/3.11...njsmith:cpython:njs/perpetuo-gil-3.11.diff
CPython version 3.12:
https://github.com/python/cpython/compare/3.12...njsmith:cpython:njs/perpetuo-gil-3.12.diff
Bonus
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perpetuo-0.7.2.tar.gz.
File metadata
- Download URL: perpetuo-0.7.2.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e790a0c99f4d5f8ff5a8fb2e0ac78079ed2e03224ae0cbd1525d5a212ffde20
|
|
| MD5 |
3ff7b38e3265823d655f2d2bdd82f779
|
|
| BLAKE2b-256 |
7a45ee874519dfe8ab459b7cf252a45c56cce787c097252e6ff4ae43810798e0
|
Provenance
The following attestation bundles were made for perpetuo-0.7.2.tar.gz:
Publisher:
build_wheels.yml on njsmith/perpetuo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perpetuo-0.7.2.tar.gz -
Subject digest:
6e790a0c99f4d5f8ff5a8fb2e0ac78079ed2e03224ae0cbd1525d5a212ffde20 - Sigstore transparency entry: 207623224
- Sigstore integration time:
-
Permalink:
njsmith/perpetuo@7333fc0a65ba526b37ab0dcd47d9b42ec232c162 -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/njsmith
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@7333fc0a65ba526b37ab0dcd47d9b42ec232c162 -
Trigger Event:
release
-
Statement type:
File details
Details for the file perpetuo-0.7.2-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: perpetuo-0.7.2-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
160baa64fcbe9b1288acee40ae6e98e08aa235f2a54cb00d342229512d776308
|
|
| MD5 |
ff69c33c972366f8cc114c3e4447a8bc
|
|
| BLAKE2b-256 |
d2f2d8547b5eaca38a8ddcb4bc0e4062c686292f00804f32b069bc7d3a874bc6
|
Provenance
The following attestation bundles were made for perpetuo-0.7.2-cp39-abi3-win_amd64.whl:
Publisher:
build_wheels.yml on njsmith/perpetuo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perpetuo-0.7.2-cp39-abi3-win_amd64.whl -
Subject digest:
160baa64fcbe9b1288acee40ae6e98e08aa235f2a54cb00d342229512d776308 - Sigstore transparency entry: 207623227
- Sigstore integration time:
-
Permalink:
njsmith/perpetuo@7333fc0a65ba526b37ab0dcd47d9b42ec232c162 -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/njsmith
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@7333fc0a65ba526b37ab0dcd47d9b42ec232c162 -
Trigger Event:
release
-
Statement type:
File details
Details for the file perpetuo-0.7.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: perpetuo-0.7.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39767fc7857042fa859bffe2db67ccd0dae478c6380cd5c74b70940b748137a2
|
|
| MD5 |
ed00c093bb7b39b0ae47380f87c2fd57
|
|
| BLAKE2b-256 |
1c42d0cdb2983c45292cdbc926fbfa720e4a902a26ab5781796c539c87b918a7
|
Provenance
The following attestation bundles were made for perpetuo-0.7.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
build_wheels.yml on njsmith/perpetuo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perpetuo-0.7.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
39767fc7857042fa859bffe2db67ccd0dae478c6380cd5c74b70940b748137a2 - Sigstore transparency entry: 207623225
- Sigstore integration time:
-
Permalink:
njsmith/perpetuo@7333fc0a65ba526b37ab0dcd47d9b42ec232c162 -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/njsmith
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@7333fc0a65ba526b37ab0dcd47d9b42ec232c162 -
Trigger Event:
release
-
Statement type:
File details
Details for the file perpetuo-0.7.2-cp39-abi3-macosx_10_12_universal2.whl.
File metadata
- Download URL: perpetuo-0.7.2-cp39-abi3-macosx_10_12_universal2.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.9+, macOS 10.12+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
378b5fe9b0b899f909f8487adb8e2f0adaf50360cf37f2c2784201f791db2aef
|
|
| MD5 |
3ebe6b01dc3390272cd61ab72d9e9f23
|
|
| BLAKE2b-256 |
66b677f5961ae42f10a910ff57dde307824a7d05deaa32aa6c8a0dbad5675219
|
Provenance
The following attestation bundles were made for perpetuo-0.7.2-cp39-abi3-macosx_10_12_universal2.whl:
Publisher:
build_wheels.yml on njsmith/perpetuo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perpetuo-0.7.2-cp39-abi3-macosx_10_12_universal2.whl -
Subject digest:
378b5fe9b0b899f909f8487adb8e2f0adaf50360cf37f2c2784201f791db2aef - Sigstore transparency entry: 207623228
- Sigstore integration time:
-
Permalink:
njsmith/perpetuo@7333fc0a65ba526b37ab0dcd47d9b42ec232c162 -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/njsmith
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@7333fc0a65ba526b37ab0dcd47d9b42ec232c162 -
Trigger Event:
release
-
Statement type: