Cirron
Cirron measures a piece of Python code and report back several performance counters: CPU instruction count, branch misses, page faults and time spent measuring. It uses the Linux perf events interface or @ibireme's KPC demo on OSX.
It can also trace and modify syscalls using strace, Linux only!
Prerequisites
- Linux with perf events support / Apple ARM OSX
- C++
- Python 3.x
Installation
Python
pip install cirron
The wrapper automatically compiles the C++ library (cirronlib.cpp) on first use.
Usage
Performance Counters
$ sudo python
>>> from cirron import Collector
>>>
>>> # Start collecting performance metrics
>>> with Collector() as collector:
>>> # Your code here
>>> print("Hello")
>>>
>>> # Retrieve the metrics
>>> print(collector.counters)
Counter(time_enabled_ns=144185, instruction_count=19434, branch_misses=440, page_faults=0)
Tracing Syscalls
$ sudo python
>>> from cirron import Tracer, to_tef
>>> with Tracer() as tracer:
>>> # Your code here
>>> print("Hello")
>>>
>>> # Retrieve the trace
>>> print(tracer.trace)
>>> [Syscall(name='write', args='1, "Hello\\n", 6', retval='6', duration='0.000043', timestamp='1720333364.368337', pid='2270837')]
>>>
>>> # Save the trace for ingesting to Perfetto
>>> open("/tmp/trace", "w").write(to_tef(tracer.trace))
Tampering with Syscalls
Available tampering actions are:
error: Inject a fault with the specified errno.
retval: Inject a success with the specified return value.
signal: Deliver the specified signal on syscall entry.
delay_enter: Delay syscall entry by the specified time.
delay_exit: Delay syscall exit by the specified time.
poke_enter: Modify memory at argN on syscall entry.
poke_exit: Modify memory at argN on syscall exit.
syscall: Inject a different syscall instead.
The when argument can be used to specify when to perform the tampering.
See the Tampering section of the strace manual page for more detailed explanaition of the arguments.
$ sudo python
>>> from cirron import Injector
>>> injector = Injector()
>>> injector.inject("openat", "error", "ENOSPC")
>>> injector.inject("openat", "delay_enter", "1s", when="2+2")
>>> with injector:
>>> # Open now fails with "No space left on device" and every
>>> # other call to `openat` will be delayed by 1s.
>>> f = open("test.txt", "w")
Metadata
Release files for Cirron 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Cirron-0.4.tar.gz | 15.8 kB | Without provenance | Details for Cirron-0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Cirron-0.4-py3-none-any.whl | Python 3 | none | any | Details for Cirron-0.4-py3-none-any.whl |
Total release size: 32.1 kB
Release files / Cirron-0.4.tar.gz
| Download URL | Cirron-0.4.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ada79cdd34e596522f9a49e99e53c635b602662e51e7e0759f98f89d0c166b33
|
|
BLAKE2b-256 checksum How to use checksums |
b8945787f7de440911eb17a8ce0e035070ecf4ba48596747f8f44f684d5ec725
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.7
|
Release files / Cirron-0.4-py3-none-any.whl
| Download URL | Cirron-0.4-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb6afbd1feccbb38c87708b24cc21134e6fe99d23238bff77fd0bb598abc994b
|
|
BLAKE2b-256 checksum How to use checksums |
368d02d428a9e32f25eef62df3ed195201059300c74b85206e26d491fafddc9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.7
|
Security for Cirron 0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.