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
  -m, --memory          Collect memory allocation events
  -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.

Memory mode

Besides wall time and CPU time, Echion can be used to profile memory allocations. In this mode, Echion tracks the Python memory domain allocators and accounts for each single event. Because of the tracing nature, this mode introduces considerable overhead, but gives pretty accurate results that can be used to investigate potential memory leaks. To fully understand that data that is collected in this mode, one should be aware of how Echion tracks allocations and deallocations. When an allocation is made, Echion records the frame stack that was involved and maps it to the returned memory address. When a deallocation for a tracked memory address is made, the freed memory is accounted for the same stack. Therefore, objects that are allocated and deallocated during the tracking period account for a total of 0 allocated bytes. This means that all the non-negative values reported by Echion represent memory that was still allocated by the time the tracking ended.

Since Echion 0.3.0.

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.3.2.tar.gz (711.3 kB view details)

Uploaded Source

Built Distributions

echion-0.3.2-cp311-cp311-musllinux_1_2_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

echion-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (852.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

echion-0.3.2-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (841.9 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

echion-0.3.2-cp311-cp311-macosx_11_0_arm64.whl (100.6 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

echion-0.3.2-cp311-cp311-macosx_10_9_x86_64.whl (107.2 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

echion-0.3.2-cp311-cp311-macosx_10_9_universal2.whl (163.1 kB view details)

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

echion-0.3.2-cp310-cp310-musllinux_1_2_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

echion-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (835.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

echion-0.3.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (823.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

echion-0.3.2-cp310-cp310-macosx_11_0_arm64.whl (100.1 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

echion-0.3.2-cp310-cp310-macosx_10_9_x86_64.whl (106.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

echion-0.3.2-cp310-cp310-macosx_10_9_universal2.whl (161.9 kB view details)

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

echion-0.3.2-cp39-cp39-musllinux_1_2_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

echion-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (829.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

echion-0.3.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (818.9 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

echion-0.3.2-cp39-cp39-macosx_11_0_arm64.whl (100.1 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

echion-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl (106.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

echion-0.3.2-cp39-cp39-macosx_10_9_universal2.whl (161.9 kB view details)

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

echion-0.3.2-cp38-cp38-musllinux_1_2_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

echion-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (829.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

echion-0.3.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (818.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

echion-0.3.2-cp38-cp38-macosx_11_0_arm64.whl (100.0 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

echion-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl (106.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

echion-0.3.2-cp38-cp38-macosx_10_9_universal2.whl (161.7 kB view details)

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

File details

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

File metadata

  • Download URL: echion-0.3.2.tar.gz
  • Upload date:
  • Size: 711.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for echion-0.3.2.tar.gz
Algorithm Hash digest
SHA256 4f5d225cb5f1d17e9969757f0c510b43a28d937ec0de7d05fb8d166a2281a284
MD5 ccf917b7fa3586d1fa6411c3ab54fd33
BLAKE2b-256 f026ef7478ca14f3a47640048bbb0082c16d851001c67d7beaee7dd07669847b

See more details on using hashes here.

File details

Details for the file echion-0.3.2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.3.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e23953e6850c070430ad18350e962077b5d997957fb54ee6d2fa2c47893b2a69
MD5 772f84db7e8fa3a8def81f247fb8385c
BLAKE2b-256 5f7764474c49239b2450ba213087ce0cb94201e94a8af60eeccf1ffbf46be4ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9facac5bac554d7d3a87371254e875d294309a40a0ff97fdd0d89de7e9762fa
MD5 05d2928e78bfd5720f2a2ef7cec1dbf2
BLAKE2b-256 4454e1e8772cb40f8c6b65bc7ee47a98900249c599db7988ccef2c0e6ea57980

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 60645d7cee665c46390453bdeddec6eb7a1ec72aa0a3d875e845a1641b3a0c9f
MD5 9907a28e378eb30760a26a04f8d2ef37
BLAKE2b-256 00403813c7e6fbb7485956652ffa8976d6128c064eb797abc8c40fc21aec153b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9080dc5543834c0f6a73119212547fd8fa70edb77eaabb5b12a4dbcb5daf48dc
MD5 7a03eb64f67ba22d6e53c943a255ea5a
BLAKE2b-256 63738e1f8c933fbf50718fcd71f0cc78da91b5281ac72b1700c5382ef3898192

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 eda48f9142bef99634d05e5dbe0c4ee0b9d7f17cb6b0ec4cbca91a9a0923282e
MD5 dc2095347f4a5440eba3be28e7c9c514
BLAKE2b-256 0e7dcfa8d2c8880564cfa3ecb099f5522092d78764999e6b71e5b09f2ed35b6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 13f36cded3d03b0185e0e11b9dbc852eb8682c025e5364a7b6c41ba65a5205f3
MD5 a4652a10c79725ff631f8e1e2f6a93ce
BLAKE2b-256 3cc39bb72fce459f58f81549cd3b07834b42d4c727a0877856b964b53c94da84

See more details on using hashes here.

File details

Details for the file echion-0.3.2-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.3.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b57fb7abf8e7ca9692c0da8d0aaf890a48097a09d9f337dc66638bcd201c1ec3
MD5 fc4ed7bbf40ca8d769e32154ae4f65b9
BLAKE2b-256 f278139c1f61cff63deb52d72e8c136978a5923aea277c34c406b02c91dee128

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d76147f685822420b4b147b3d70d8118c8b52d664f43756114b17d1019ff043
MD5 98e5c1080f1d71f2ed32d6d887715a72
BLAKE2b-256 d92a66fdc8fa36e723a32c1722670d4a7c591dff92eeadd6dd27d58c49515365

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 369c3f5f45fe84d663f678903241c4202779e5ce256ce3260358bd8d5933b0a8
MD5 5ea4b4a137ac2cc801759a5c02aee3e7
BLAKE2b-256 4bd6a40f9110fbb9961a044bc8cbdcd89649bd25d096339ab28c3978ebd01701

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cce3f9120cf2cf077cf796150ceabc770ab26e3a38488714ca5579030ef5361e
MD5 68c3716277c6902fabe2d564d2096e8b
BLAKE2b-256 fd2f973b873805f52e982111dfd66c3fa7e0e6ef4ffcb52d4e7e332c9ffebc4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d4a2d6c378258bc0c9a14567f8ee36ddbe85b4459ccc6bb15320e6d322398041
MD5 545b4791a61a3fffb3a35abab0d56cb3
BLAKE2b-256 30434f4d25190993d8f83722324e697d1ea21c2998461578981208f24cd42711

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 6a8936850bc706371d2f4a0c3d9ac2c1d448002f632c9f79c7d6d303c451a4cf
MD5 fcdfffd24b12aaefa82823eac16ff93a
BLAKE2b-256 cf222809e305cb3c0bd054b639674c4b22517c5d131c6b35087db1083ea0095d

See more details on using hashes here.

File details

Details for the file echion-0.3.2-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.3.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cc4565deb51713da4e0cf44a24a39393cd07f89ac26ea7d01ee93fbee5feb10a
MD5 24dd8fa6a838dd36016a80630d0acede
BLAKE2b-256 22f5701d8804aca649afbdc76afa046eb1ad1e81eee25580a725899b071d9f2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5c6b0963940fd0a5a2d8d01f8f1854d5e580a73aa6dc6493e6239619bce0c5d6
MD5 3ede5afdd3a37d108491621120e93c55
BLAKE2b-256 9e693c8cc4a0f0a4bc0846cf7f2293cbd60ff855620f31c465ec6028d0f1e793

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 613aca7329c732fdf7d6b509d81be74ed8455023d542e73874882d44ca3fa528
MD5 7340dd029049dbeb8d2b6d3ab9cd3fd0
BLAKE2b-256 d2f9864c9ec9567b072be747db4d6bcbb0797cbe10a46a40a7e0988852c1f7ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a44e89d691091db2e4c314258acb033294dc9bf4bc63f3d7cd985961b9365c6
MD5 8a30831e19d5a14b235c5ca34b28e5bf
BLAKE2b-256 1e800f7eda800db493950472f8b611ea5a1006ab6d763c137a3e3dd90f84ac3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 586ef8c2e13bd18f96b8096d2a0cc8e15b05fcf11b6c6a1e2863de5aae6963c6
MD5 6458f1c42c248fb1f3833f23afc6e618
BLAKE2b-256 4e0f917a3b5b78ee10d8f5ee18fd21d3cf0f00681c7a7310374282766759cff7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 cc1a110c6e20036f6ab9b93aa3eb74b2f7553d59ac7b711bb884880e7b6cad85
MD5 62024e92208672c2211547d31a9cf192
BLAKE2b-256 6713999f0fa1f537844afb46258fd13bafe2144a6078a32f766b4f12da2e1d72

See more details on using hashes here.

File details

Details for the file echion-0.3.2-cp38-cp38-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for echion-0.3.2-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 37f7a285579564beb0d9ed2bf9958c13e162347c56eda07018472e5064e504bf
MD5 53a583727dc9d673951468b2922a430d
BLAKE2b-256 f99cd0194eec2572eca8a567f71b18c9ee07ad0a930b1039c775671f6f139fea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 496004dd3d98500b6a241c357070a18b925af018fc07b4c56f061e04e0efc6c9
MD5 ad62e877dbd5a0270d909309518c68c6
BLAKE2b-256 bfe3f3996041acecbc65b6975a3635f919df60b901167c28f05cb9273ee45955

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1be711ef6ab46e2470740cc4955248921a2c23a5b67a3051a327e229fc1ba139
MD5 05e69a1206c6f204a92cf8faaa5acdfa
BLAKE2b-256 3b33f91a22f03cd1d5d5df791eb620a6a790b53f1a37413e7efdc04d9d687a74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 865088cfb5f5eacde0a2cdd3e47839364d12f0a01e639ed7d891d2ebe69e8961
MD5 4ff981f189fc41fa5c801a88f7ec3ec2
BLAKE2b-256 b452f96ba508d03437c9d09b4448ac713fe97d97c8ddfa05b7f9f28042aca778

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 780f4fe84f4ef3f055aca53045803d01b4eeb785dd19f3d57422508dca7b5ac1
MD5 3560424fb7bc16f3da94b0d3069e72c1
BLAKE2b-256 d7b9eee7b906a03a78306a8f55952040db2ef505b4f32ddf05e091a2247eeffe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.2-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 cb1822da985abc94ba0eebc76f6bd007dc215feafc90851de32a92445f7e1a79
MD5 b7461e24253789c3ee49242a67e0abe1
BLAKE2b-256 620e61c8eddc177a1ec6f3068c7852067dd9115b0565c5f359e2980c46dc990b

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