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

Uploaded Source

Built Distributions

echion-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

echion-0.3.0-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.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (842.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

echion-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (100.1 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

echion-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl (106.7 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

echion-0.3.0-cp311-cp311-macosx_10_9_universal2.whl (162.7 kB view details)

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

echion-0.3.0-cp310-cp310-musllinux_1_1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

echion-0.3.0-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.0-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.0-cp310-cp310-macosx_11_0_arm64.whl (99.6 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

echion-0.3.0-cp310-cp310-macosx_10_9_x86_64.whl (106.0 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

echion-0.3.0-cp310-cp310-macosx_10_9_universal2.whl (161.6 kB view details)

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

echion-0.3.0-cp39-cp39-musllinux_1_1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

echion-0.3.0-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.0-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.0-cp39-cp39-macosx_11_0_arm64.whl (99.6 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

echion-0.3.0-cp39-cp39-macosx_10_9_x86_64.whl (106.0 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

echion-0.3.0-cp39-cp39-macosx_10_9_universal2.whl (161.5 kB view details)

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

echion-0.3.0-cp38-cp38-musllinux_1_1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

echion-0.3.0-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.0-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.0-cp38-cp38-macosx_11_0_arm64.whl (99.5 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

echion-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl (105.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

echion-0.3.0-cp38-cp38-macosx_10_9_universal2.whl (161.4 kB view details)

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

File details

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

File metadata

  • Download URL: echion-0.3.0.tar.gz
  • Upload date:
  • Size: 711.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for echion-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4094eb67c3b42f155731a0569747d46058c992f7e4c372130cfda6c2aa7d1ace
MD5 9017d086b6bfb65404e38045be0b25bf
BLAKE2b-256 6ebd27c99952215edb2d519bec8d0257a45fff1e5a43c43262965afdc0c8441d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 265d7c3d6ddef0f0b1c72b4c4513ec75858c8f060aa060feb4c2e61949e9448b
MD5 f2ca43715e3e9e936ab4a48ac25c5fad
BLAKE2b-256 172879cb6b9e35a344ed0d80f062a25d268135f6d44087729b73d84e1db54f31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4389c6b3c60a562a6a960dac69b4e2f76a1aa9fa12823c5bcfa6d56d9efc98b
MD5 5969dfe674b0d1c238c0a8fe9071f528
BLAKE2b-256 64682c050c01913581dd426d9784e0cae5ebf8bfc75f1ec64e69dddc500a734a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a89b608dbe9899d9569047d35af85c601a95b3c952fa17e492f17b884629d15c
MD5 3b1ec08d6e9dd137dfcf7d7f6d695e38
BLAKE2b-256 9eead40db1e1d6466d9b9e5d12b1c80ff43ed34904d4472adc038cb0151acaa0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fa46ca3693fd3231b6945eca3eb66111ae4aedd9fd0ca85313b37d4f99cc96ab
MD5 bc17cf51cc17bdeeb5d0406474da5964
BLAKE2b-256 647970264af5bc10e8b81d57543aa031395f3d0e538323391cf8fa62226c6cd5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9213971cb536c56e7a3f5cabe4aae3e68b711df3259f695e865811688219533e
MD5 348b517bb6c78c8b0432204269e19a08
BLAKE2b-256 e4644875ed7ac70baecf9721ad6b1550b4f4099d1ad38968b137eece8a288c99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 f1e690e999d5c72fd574045a3924dc653d2b00f1bcfa4d9a4aca5bd1846a2e72
MD5 72240208cb6d56e52db82fd9bbc6cb95
BLAKE2b-256 310eb3f072026927875fd0c6b4c13e593d7ce3bdf717bd524d2a156ff69af959

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ffcccc33f11a96dfbe1c67d1b276ba90d36d225a2836206bb13665b989a8ce6f
MD5 2b39b117709d38b3ba47cd5c49caf81d
BLAKE2b-256 414641c7f8a52a999f141061ab6f9a34e2c91f36502702ba131835035ea738c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd8e1bb3c861aaa68510bcf25957f36c7b6cb5dd2a712a3461ed1bbbe27360af
MD5 7737e88f9c7a269c586d5a9ecbe3065a
BLAKE2b-256 e85919d0f75be83fc9a8ed5baa872f0eb9840b2d1e5347be1557c233370e2166

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 dd7dcbfc665f560f1ff2d91141ddbb0bef923d7253a8b0153694981040a9010c
MD5 1dfd7fbe3bc8def0651ab1c2f97c3b30
BLAKE2b-256 9db684465938b1635b555fa48cc2737d9d2f41aaa18f2f4b18bcbc59e9d59e94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5973f36b59f69fccc5ff7d903b796e0c76b523b4d385ee3cd3a310344d728a88
MD5 9d2f3cd5aac82218e30a9dd9a30d96f5
BLAKE2b-256 07a801747a9a4bac075a27bae41d4e75ee7656a78b2130c951dbd175e17451a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2b67961258cfc89b09bb0976f03f547bae51c0668e28cd8f09bd646feb66b20f
MD5 f8ff8d5a26455d75b7a0dccd92c3b62b
BLAKE2b-256 c370a5e4de57a7a61813b751ea7b5a618d878df07940dc22976b5d05325c55de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 07c9e1dacceffefb02343f1a799db9bf4a2b6e961880c6faf8b46f63daaa9a81
MD5 e01762ff63d5ff259cbed1933739c481
BLAKE2b-256 910e9c146001e4762f6fa539bae732064d112284d2b564349178fc459ec3d73c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 db70a0ba7df8f5e50913bdc7eb72f4138ff5f9eadf6a687cb9c28ac0e14bc96b
MD5 a2d3470201a8334553d52166f1342a79
BLAKE2b-256 4e2026f14ec4be7f72faa6326d2a67b2534929d0ef6ec828c2580ed3243761ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 449f8a5370b3f8b918b1b118395f7b3b756b75ddaecaf9ff87ee6e6488c305d3
MD5 efe2f28abc43b24d893e3f6b5e4c1f3a
BLAKE2b-256 a1dcefc4618ad27cf4cdab1d87519553b6b658a5a75fa86da5781bf33527e120

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4a98431efde6be447ca484e7f2425ee39b3bafd82df02223aa0a05e85de465ba
MD5 641f149aac6e0cb48310a0198a22ba5b
BLAKE2b-256 f499ed3c2428b525ed1879a7bcd762730de686d627a2bc313d871a83ebda3db7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0833dab8aa5461b8d77937f406ae27a81322fb9a8449f79f332cec41bc852120
MD5 30a1f2e0c07c8f36cd34d6386d6e4eb4
BLAKE2b-256 b777b668c85c4fbac6e0779d980a699de157452d0b289e83828d5b826c56c04f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9f7126d30f01e082c6807a56620aeffc7f87b1728f3a405e021844c079d02cb3
MD5 38789754e0b49ca2631d8b4e5d245740
BLAKE2b-256 13dea7f9c5bd2957aea73e18453508227df22f46accd40b717552e1569332b4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 69c8bff317eba795e2fcee2f04c597e3573279557d44d24674fd1b8c33b6b7f6
MD5 31f17033f3b75bf5d95fd47d9b6c6461
BLAKE2b-256 96539985261805d22592cefc7fdb418d53a459b032916ec3c6128885f8474500

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 9d911f5bedbebde6e1ae8a2ae42b9c742f903dd02b0d691e6fa018ab068c2b55
MD5 75512335c173b620a08ea4797f34f62c
BLAKE2b-256 8435f809c717a8426567231b947ea6904618f9f362878de07c6177770dc1d7f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28b24a963053c933693bde33aae49527b3b7a46df21ca5ec4717ffe66b86db0d
MD5 3272a0bd318ac206cb1248107b4a0db5
BLAKE2b-256 fe80a08a7f25cfefac09fe98b31e917aa4785b99d6a878954f4c9a492ef402cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 d8faf842a4cadeb6749dd4dc6a6a6aaa80087f85c75069074581f961780ad3b3
MD5 e6c1854989332896c402bd482a71501b
BLAKE2b-256 894162ccc35e415f4ecfa539a4f276b670406b1c186b553a4ee1d6359d3abc08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d7b3771ef727c0c8da2d77ff2032d7dc97a140f1b07e4623fffc987d5c56b92
MD5 7b9a8fe84ed1902111c06cb8c691eed5
BLAKE2b-256 918679601e2f33b8d1b32e304146931adaf45a380a46840a15f48b87454b11de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8134567139c0a314e2ee328537ba8b753bd568b584731cfc1e8765d2a6eddef8
MD5 c4702246f801308cc79d816b95aa7051
BLAKE2b-256 bbd65e7ac5664133c07a33aadfbecab8cfcf8a9893f402ea98bce40c73f6104d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for echion-0.3.0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 196f93146ece7a1d8d9f8e1bfdb5c7bfaa2f9de224fa9778adac937bb7142958
MD5 893e2afed3d94d107018b427feded77f
BLAKE2b-256 6e5452d00d43e5f8bf1ad4c81a56985d828b01996c60dcdb9a31b3dddc564dfe

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