Skip to main content

Rust-powered Python profiler: in-process, no sudo, CPU + memory

Project description

Bijli ⚡

Rust-powered Python profiler — in-process, no sudo, CPU + memory.

pip install bijli

Why Bijli?

The two most common profiling approaches each have a fundamental flaw:

  • cProfile / tracemalloc — in-process, no sudo, embeddable — but adds 30–100% overhead. Unusable in production.
  • py-spy — near-zero overhead — but requires root (ptrace), can't profile memory, and can't be embedded. Its low overhead is an architectural side-effect of being out-of-process and never touching the GIL.

Bijli is the only tool that combines all four properties:

Bijli cProfile + tracemalloc py-spy
No root / sudo ❌ always needs ptrace
Low overhead < 5% CPU, < 1% I/O ❌ 30–100% ✅ (out-of-process)
Memory profiling ✅ RSS + allocation sites ✅ (but always-on cost) ❌ CPU only
Embeddable @profile, with Profile() ⚠️ programmatic but slow ❌ CLI only
GIL hold per sample ✅ < 50 µs ❌ every call ✅ zero (out-of-process)
Python version lag ✅ hours (stable C API) ✅ none (stdlib) ❌ weeks (raw struct offsets)

In short: if you can't use py-spy (no root, need memory, need to embed), bijli gives you py-spy-class overhead without the trade-offs.


Quickstart

Decorator

import bijli

@bijli.profile
def process_data(items):
    return [expensive(x) for x in items]

result = process_data(my_list)
# Bijli prints an ANSI report to stderr when the function returns.

Context manager

import bijli

with bijli.Profile() as p:
    run_my_pipeline()

p.print_report()          # ANSI to stderr
p.print_report(json_mode=True) # JSON to stderr

CLI

# Profile a script
python -m bijli my_script.py

# Profile with arguments
python -m bijli my_script.py -- arg1 arg2

# JSON output
python -m bijli --json my_script.py

# Custom sample interval
python -m bijli --interval 20 my_script.py

Installation

pip install bijli

Prebuilt wheels for:

  • Linux x86_64 / aarch64 (glibc + musl)
  • macOS x86_64 / Apple Silicon
  • Windows x86_64

Requires Python 3.9+. No external dependencies.


Output

================================================================
  bijli profiler report
================================================================
  wall time  :  2.341 s
  samples    :  46
  CPU        :  avg 12.3%   peak 97.4%
  memory     :  44.2 MB -> 67.2 MB  (+23.0 MB)
  spikes     :  1 CPU detected

  CPU  [_______________________##########_____________________]  0%..97%
  RSS  [_________________-----------############################]  44..67 MB
         _ = low   - = medium   # = high

----------------------------------------------------------------
  HOT PATHS  -- where the program spent its time

   1.  process_batch              34.8%  ##############
        my_module.py:88

   2.  _transform                 21.7%  #########
        my_module.py:61

   3.  sum                        13.0%  #####
        fromnumeric.py:86

----------------------------------------------------------------
  SPIKES  (1 detected)

  1. [CPU]  0.85 s -- 1.23 s  (380 ms)
     peak 97.4%   threshold 34.2%
     Stack at peak:
       process_batch             my_module.py:88
       _transform                my_module.py:61
================================================================

Configuration

bijli.Profile(
    interval_ms=50,   # Sample interval in milliseconds (default: 50)
    top_n=20,         # Hot paths to include in report (default: 20)
)

CLI flags:

Flag Default Description
--interval MS 50 Sample interval (ms)
--top-n N 20 Hot paths in report
--json off JSON output instead of ANSI

How it works

  1. Sampler thread — a Rust background thread wakes every interval_ms, reads CPU% and RSS from the OS directly (no psutil), walks CPython's sys._current_frames() to capture stack snapshots, and pushes samples into a lock-free SPSC ring buffer. GIL hold time per sample is < 50 µs.

  2. Spike detection — after stop(), Welford's online algorithm computes mean + σ over a baseline window (first 25% of wall time), then groups contiguous above-threshold samples into SpikeEvent objects.

  3. Memory spikes — when RSS delta exceeds the threshold, a Rust atomic flag is set. A Python daemon thread polls the flag and activates tracemalloc for 500 ms to capture allocation sites, then restores the original tracemalloc state.

  4. Report — spike events, hot paths (by frame frequency), and allocation sites are rendered as an ANSI report or emitted as JSON.


License

MIT

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

bijli-0.1.0.tar.gz (61.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bijli-0.1.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (269.5 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

bijli-0.1.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (269.4 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

bijli-0.1.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (270.1 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

bijli-0.1.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (271.5 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

bijli-0.1.0-cp39-abi3-win_amd64.whl (161.9 kB view details)

Uploaded CPython 3.9+Windows x86-64

bijli-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl (487.6 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

bijli-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl (449.4 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

bijli-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (272.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

bijli-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (246.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

bijli-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl (255.4 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

bijli-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (277.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file bijli-0.1.0.tar.gz.

File metadata

  • Download URL: bijli-0.1.0.tar.gz
  • Upload date:
  • Size: 61.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bijli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0df1cd81db1ea666580839cdf174245c8c087a723642711c6b8ed559fa98edf0
MD5 ebb381e998cdb4d99b6ce961d4977ab9
BLAKE2b-256 72f91b8d856aa28c79b96ec092988a67504a9f936c64e7d3f56083c3b8a276eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0.tar.gz:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bijli-0.1.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7f9d4204a589caf1659a90b83085a81821cc4eebfa98e4d1c9c4346633063f60
MD5 766356359fa379916e8696022eb91419
BLAKE2b-256 3bdc50f7468c45f9557674732f1ab980497f411abc69e007194b99bb3df93258

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bijli-0.1.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 927c2dd10f881a477d39055a2975ab1759606fa13d298ae5a88f0363528ea61e
MD5 d9b063c5f8b5b661a1189958bc44ab4c
BLAKE2b-256 0b1daef55480b8f97ba16cb51fecd26b596913eda2ce7a81969017ec04cdd7e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bijli-0.1.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 97763909b422c6b7e76b5ee569e6f46c13faa8c34e81dc9d4404044cd6f7dc89
MD5 9a3de2eea64d732a75016b163f2baaa4
BLAKE2b-256 a706c41cd20477051edc68a14186e7617921b49d772c5382321f88ea7a38ddd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bijli-0.1.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 52858e08d53d1684a91dcde590a1ef25674e4e56927f03d78de71806b2af9827
MD5 b3bb9f3b9d1f04cff0ecb6502694fcf0
BLAKE2b-256 b4b99f5d336bdb4665fa09a591a8526f3e569be02da2cf1060aa117b2225be1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: bijli-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 161.9 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bijli-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 19f683d96e4779b61d1a31da7d13a5e1e4939b855733d9ed87d9b63dbef2458e
MD5 bc83c4aa05e0d62b4840a6b458ad5c20
BLAKE2b-256 15c2817468eb43c6cf674ef219205c495a9e48b05d260de57f8c3e9ffa9585d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: bijli-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 487.6 kB
  • Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bijli-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 41c808281f74ed549709845746f136ced80ba532aee84965ecd5cba4fc8d23e1
MD5 3da759cd947b03072639a50a5530d7df
BLAKE2b-256 539e686eed4e435d7e2ed559cd7d760f4888e9679ce17dfc66b26907423bb4c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for bijli-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 96c8bb394aff5b8a1b430620038a0df6f5ef9c2b4fa4b2c9424640d52fe0befc
MD5 ad0b9eabfd4e7c13a73d18daa996021f
BLAKE2b-256 9771a5ae52e8ca855a771df92f3edb24c8cb00328dae1e4e5cb1fbb303c33971

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for bijli-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1c745d0cfb814e6ee86dba119f06f77e928e40c87867f5f44414acc2c866c61d
MD5 fa80f771585f6f29b35a32ad5d8a3002
BLAKE2b-256 418c50fb85c73b43055c98ce792ec219e18335ea3c50753c02ca67f48770fc6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: bijli-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 246.4 kB
  • Tags: CPython 3.9+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bijli-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e3619da0f8dfa597e6a7fe6642a4b9d2784a0325324bb82d62acd1bee7730ec0
MD5 c53c2eac38b9665188420d331a412b48
BLAKE2b-256 2ab05993ffcfb4d7cdab9553eeffcba4520800593bc48ade302b1699493f0190

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bijli-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a7235db9cbb9187cb26aa439e8623eb0d1594139a72a23831b33e439069e868c
MD5 a1516804045f07ebe6667510db471c24
BLAKE2b-256 f1f31448d6621dfdfc1bfc33ed59e6bb69117d0184b472029c04157904cdac5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bijli-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bijli-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1fe0412536eb0622a1b6731a4393e6a001347f03009bc673a9750c74125c36c3
MD5 a4cbd922bc25be470a0a99ae90a25f6e
BLAKE2b-256 f503ab6056dde3b8a0228d0f691cd3e7020060a5cbd60220b23d4600d210daa1

See more details on using hashes here.

Provenance

The following attestation bundles were made for bijli-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Yakksh/bijli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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