Skip to main content

In-process CPython frame stack sampler

Project description

Echion

Near-zero-overhead, in-process CPython frame stack sampler with async support

Synopsis

Echion is an in-process CPython frame stack sampler. It can achieve near-zero-overhead, similar to Austin, by sampling the frame stack of each thread without holding the GIL. Native stacks can be sampled too, but the overhead is higher.

Echion is also the first example of a high-performance sampling async profiler for CPython.

Installation

Currently Echion is available to install from PyPI with

pip install echion

Alternativey, if a wheel is not available for your combination of platform and architecture, it can be installed from sources with

pip install git+https://github.com/p403n1x87/echion

Compilation requires a C++ compiler and static versions of the libunwind and lzma libraries.

Usage

The following is the output of the echion --help command.

usage: echion [-h] [-i INTERVAL] [-c] [-n] [-o OUTPUT] [-s] [-w] [-v] [-V] ...

In-process CPython frame stack sampler

positional arguments:
  command               Command string to execute.

options:
  -h, --help            show this help message and exit
  -i INTERVAL, --interval INTERVAL
                        sampling interval in microseconds
  -c, --cpu             sample on-CPU stacks only
  -x EXPOSURE, --exposure EXPOSURE
                        exposure time, in seconds
  -n, --native          sample native stacks
  -o OUTPUT, --output OUTPUT
                        output location (can use %(pid) to insert the process ID)
  -p PID, --pid PID     Attach to the process with the given PID
  -s, --stealth         stealth mode (sampler thread is not accounted for)
  -w WHERE, --where WHERE
                        where mode: display thread stacks of the given process
  -v, --verbose         verbose logging
  -V, --version         show program's version number and exit

The output is written to a file specified with the --output option. Curretly, this is in the format of the normal Austin format, that is collapsed stacks with metadata at the top. This makes it easy to re-use existing visualisation tools, like the Austin VS Code extension.

Compatibility

Supported platforms: Linux (amd64, i686), Darwin (amd64, aarch64)

Supported interpreters: CPython 3.8-3.11

Notes

Attaching to a process (including in where mode) requires extra permissions. On Unix, you can attach to a running process with sudo. On Linux, one may also set the ptrace scope to 0 with sudo sysctl kernel.yama.ptrace_scope=0 to allow attaching to any process. However, this is not recommended for security reasons.

Where mode

The where mode is similar to Austin's where mode, that is Echion will dump the stacks of all running threads to standard error. This is useful for debugging deadlocks and other issues that may occur in a running process.

When running or attaching to a process, you can also send a SIGQUIT signal to dump the stacks of all running threads. The result is similar to the where mode. You can normally send a SIGQUIT signal with the CTRL+\ key combination.

Why Echion?

Sampling in-process comes with some benefits. One has easier access to more information, like thread names, and potentially the task abstraction of async frameworks, like asyncio, gevent, ... . Also available is more accurate per-thread CPU timing information.

Currently, Echion supports sampling asyncio-based applications, but not in native mode. This makes Echion the very first example of an async profiler for CPython.

Echion relies on some assumptions to collect and sample all the running threads without holding the GIL. This makes Echion very similar to tools like Austin. However, some features, like multiprocess support, are more complicated to handle and would require the use of e.g. IPC solutions. Furthermore, Echion normally requires that you install it within your environment, wheareas Austin can be installed indepdendently.

How it works

On a fundamental level, there is one key assumption that Echion relies upon:

The interpreter state object lives as long as the CPython process itself.

All unsafe memory reads are performed indirectly via copies of data structure obtained with the use of system calls like process_vm_readv. This is essentially what allows Echion to run its sampling thread without the GIL.

As for attaching to a running process, we make use of the hypno library to inject Python code that bootstraps Echion into the target process.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

echion-0.2.0.tar.gz (705.1 kB view details)

Uploaded Source

Built Distributions

echion-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

echion-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (743.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

echion-0.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (730.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

echion-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (78.0 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

echion-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl (82.7 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

echion-0.2.0-cp311-cp311-macosx_10_9_universal2.whl (124.5 kB view details)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

echion-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

echion-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (745.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

echion-0.2.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (731.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

echion-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (77.6 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

echion-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl (82.2 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

echion-0.2.0-cp310-cp310-macosx_10_9_universal2.whl (123.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

echion-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

echion-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (744.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

echion-0.2.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (731.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

echion-0.2.0-cp39-cp39-macosx_11_0_arm64.whl (77.5 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

echion-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl (82.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

echion-0.2.0-cp39-cp39-macosx_10_9_universal2.whl (123.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

echion-0.2.0-cp38-cp38-musllinux_1_1_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

echion-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (744.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

echion-0.2.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (730.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

echion-0.2.0-cp38-cp38-macosx_11_0_arm64.whl (77.5 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

echion-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl (82.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

echion-0.2.0-cp38-cp38-macosx_10_9_universal2.whl (123.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file echion-0.2.0.tar.gz.

File metadata

  • Download URL: echion-0.2.0.tar.gz
  • Upload date:
  • Size: 705.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for echion-0.2.0.tar.gz
Algorithm Hash digest
SHA256 eba317668a9baecb56e6f37b733cc1892c90c19abe2071e10a36203e4c47e1eb
MD5 61e48eb9eac6fdb2fcf37025d49180af
BLAKE2b-256 4a7a8e9b0856efbe2d8ec8fb86fe48957902c79b5152a7269078b557f632c01c

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b318a76198b3f5924703ecec59c12d6862d89af15890e533b6aaadf3f3295e53
MD5 14af8f274768d7b98bd1de2df7ff4833
BLAKE2b-256 8353445c466452bc643d902c7dcf55dd818ce9f60b6cfa3cd315d6beb9010e32

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ceedacc9fa59147262e01ed701ccf35e98273ddf5740276aa090fa115589bc0
MD5 fc6d9bbcbe3feb8a8a7e219d70c34fae
BLAKE2b-256 b4cc903d2baea8ccb7d9530b65733c5b718a95ecc0524e8613bf9031ebf0b21e

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 8258c1eeb6203c11d0f97118a839f7103ae8b41a86a4511eef30b3020c9b41dc
MD5 6b270313651f284026edcf7e225b57dd
BLAKE2b-256 cbf15bfeb1df3062a5710a4bc087bded514741c768dfc57af4334a70d3dff2ca

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9bc3e48e58b0937d003ffa62b81da982cfec42998ed44c00acb3823c4ab4f354
MD5 6f53aef26fa8dbb58879e6ed6b1dd342
BLAKE2b-256 304d5e2e334950766f84d1558e1d907803299ff711a80e391e39688c29c4e97f

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 87efc5671c08f817704477d1cffe5ee8e0626bb646c0cb9568cf74d8d1ea12d8
MD5 37d6d709ba460ea65695f1eff889bcd3
BLAKE2b-256 3c3efa82a30c7a6930981abeea9150338257a445e3120a4bd5ead06ca0bae617

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c7d15da9aeb40eaab1c340ba0de3856a86607dbd0e16a94001f1f2f3f8894248
MD5 f27a5e579216781bb9add39f8363db89
BLAKE2b-256 6a29b86f4883b184a083a1386abf8b20c0cf1b25006303b0492af433cad900ad

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 bc09c6da72874b53c3e312fb0b927760dcfb806feba7ee0cbd943aacc44f0c46
MD5 c9d98358214dea2f566d6f532c967230
BLAKE2b-256 12b5ea3b3a32094d52023898d0a7ea2d3fa9809c7b1d9defa9cb8e70090ab240

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 87cb198d8e5199c7e93c93c6ade2f4bc06142727c9b7d785dec75f5fc3af3e19
MD5 2c10b28d7631abc61ca95dd7b930d995
BLAKE2b-256 b8529030a63dcffef9cea17cc8a2c445b2d1376eff6b90c26aa6b171c7193be9

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 5099a381e3ce1767b658b969cbd89b030dfbf72d13b52edb867baa413ca9b035
MD5 c85c746162028c4a2c9d3a3e95ff977c
BLAKE2b-256 631cf331c6cec268e0e150a901206ccc59460e445f569d2e7b208205c3d8b19e

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2d429137f7d24c0ddf3ff482b878b878d54be69cbe8d3c792faa62e1f0618a2
MD5 a377b4fa4eea4f8498096980f66ec49d
BLAKE2b-256 b25517dc2b423b1ac943d64f52ad0ec79a1f87f70379f7936d24a96b30663f2d

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9902ea4dc00bb8da3b6361983434115d7ab1b561812be312456b97191c5b8b04
MD5 3aaae9093c6a13d89eda6ce0e5857a51
BLAKE2b-256 1e5a097c4aaa9faa5fa2f5f2bd74a02982966ef80e9cd521b1d2c64e4067fd75

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 2cc0831b0c473496dca2a0f3e3c201406238d9908e4bb045eb50ec8388d4a62e
MD5 eed1814f120f7988299df967ecb8fff7
BLAKE2b-256 b88ba604d105ec989fbd3945fb98f0fad76eb0320f69ae63c4cb7b3051c3f630

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 d91af6dca3132f9ef020ad5ca81edb1351ba137ccd821b2a013898fc767127fc
MD5 fff192674f75fdd914d5314950c4e4cc
BLAKE2b-256 a03c91463341aaaae8825581c412392b13d950a4ea01c5c92bdfc36fac7e3d9f

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b4e3d0a749d39b8130863834266fcd2598e882dbc7a3f0e5ff80a788fe2c76a7
MD5 6e799b1dbda829a4ea969e91a1fae59a
BLAKE2b-256 bc9c90665e558301a95d01f51ba9f98c95db9d4f1b78b87f934ed74003117b24

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 5e51b01c9ca31ee9d04640b182f8a1a1dfc535036798499e5c7d19b1bf441122
MD5 954c142c63d01d037eb29023169e4b9d
BLAKE2b-256 a3d05cf9ae8fd7d07fcb198e113abbb0140f1483fd4734fbb5e7f68417fa5ebb

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4329f09897285f16c25a97737143f3e0db6079e824d68e1b78e4a7655cf77aff
MD5 949303358e904ea8dcb15cb4584896ce
BLAKE2b-256 720e904c4fb081401777178381c86cbba2623e44bac8fa57cbea4244fb09004c

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b477d82a352b5967167a2e476ae5077c7f64486df9182fb13a751b3b6698687c
MD5 bcae5e0ff46479250e43d611fad8fe12
BLAKE2b-256 1d0a665cd5c36797d0bbd15d4b2c1d646f00d849d8cce47fd11b01457e3b313e

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 eceb683022393b929308330763ce49e9d71497cb699769a6b0f62ae28dceb69b
MD5 da55c299f6f5b6941efb873fb05e0927
BLAKE2b-256 b16fc4605294f094ac9f812264be745b83c38510fc75588e5e4a297f0744cbad

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 5b35531dcd6cdb0bb9c8a9a2fe4a09fdc4e6776c7ef2f34093a1c91e633a1b30
MD5 348565a583d9bc667a7c9a67b5ae3038
BLAKE2b-256 99c95a8a78a1eca294de491baed30411f1e3ad38626ef27ce6af87618fd9113d

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 540e0f5b50bfa5de89234ffd26bec5e68a9c095dd177110bcffa0e04698070b7
MD5 c807faa3799689e69764042dbf3b19ab
BLAKE2b-256 513897e2be494374501cc39d61d3828f8b67685ff9442c59e14f34e50e936069

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a267350b52dca202afc873847f051f84830d44fc5f01cf306e9367de8ff00e09
MD5 f5fb907e2a0479eda586795fbab04b31
BLAKE2b-256 02d2c3fa87e83f56196b1703b12ba839cf6a7a1808b7baa469fc09f2fa5415db

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8644ff99d5a5f99ac17d99070c6fadd6dffb5f9094c440610c45ee901b9b89c5
MD5 a715dc9f7a1e493f815187d73855f7c4
BLAKE2b-256 72765fc65193f51b7bcacd7f292e092998f35dae1c1d819412919a025c996650

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8212de3106cad34f28493630e58cb69d0dca83045ef480517de12aac4f880891
MD5 0863834aba6ab402e06f2c5490486340
BLAKE2b-256 c5ddff0235ef39a02a03f1766a7c979f24313f1daf3fc8d18ad56e309dac2d3b

See more details on using hashes here.

File details

Details for the file echion-0.2.0-cp38-cp38-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for echion-0.2.0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 035e898b457980fca245227b535f51ac637eecd1f3ca084d87c0446fc103185d
MD5 f989f6f89cc84da38a78ff775272d75c
BLAKE2b-256 075713a22cbe9fc62380a51d2d103dfda55402acc2dbd19463fc5a4aac86d5d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page