Skip to main content

bottlenecks

PyPI Python License

Finds bottlenecks in code, runtime, pipelines and the host system. You can ask in Polish or English, type a canonical DSL command, or call it from REST or MCP. Every run is recorded as a uritime/urtlog event, which gives you history, regressions and scheduled scans. The core has zero dependencies.

"pokaż 5 najgorszych wąskich gardeł w kodzie src"        ← NL (PL/EN), Layer 1 / 1.5 / 3
        │ compiles to
code.scan path=src top=5                                  ← canonical DSL (single execution surface)
        │ Engine: registry-validated, effects-checked
LOG URT(at=…, range=…) URI(proc://bottlenecks/code/scan/v1?path=src)
    URN_IN(urn:bottlenecks:input:…) URN_OUT(urn:bottlenecks:report:…, urn:bottlenecks:finding:…) STATUS(succeeded)

The architecture follows wellmanifest/nl-dsl-llm, nl-api-llm and nl-uri-dsl-llm, with a uritime/urtlog record v2 ledger. See the decision and the architecture docs.

What it finds

Action (DSL) Finds
code.scan nested loops, blocking I/O in loops, += string building, regex/sort in loops, complexity, long functions
runtime.profile / runtime.pstats hot functions, call overhead, recursion (cProfile)
pipeline.analyze critical path, choke points, fan-in, serial chains, worker starvation, saturated stages
pipeline.urtlog in recorded executions (any urtlog events.jsonl): slow, failing or tail-latency operations, the lineage critical path, handoff gaps
system.sample CPU, run queue, I/O wait, memory, swap, full disks (psutil optional)
history.diff / history.trend / history.lineage new, worsened and resolved bottlenecks between runs; trends; URN lineage
plan.schedule / plan.run_due recurring scans as urtlog PLAN records

Install

pip install bottlenecks            # stdlib only
pip install "bottlenecks[system]"  # + psutil

Use

# classic subcommands (unchanged)
bottlenecks code src --top 10 --fail-on high
bottlenecks system
bottlenecks pipeline pipeline.json

# natural language → DSL (PL/EN; prints the compiled DSL)
bottlenecks ask "pokaż krytyczne wąskie gardła w kodzie src"
bottlenecks ask "check system bottlenecks"
bottlenecks ask "sprofiluj skrypt app.py" --yes        # process effect needs confirmation

# canonical DSL, autocomplete, REPL
bottlenecks dsl "code.scan path=src top=5 filter:domain=code"
bottlenecks suggest "code"
bottlenecks shell

# history in a urtlog-compatible ledger (opt-in)
export BOTTLENECKS_STATE_DIR=.bottlenecks
bottlenecks code src && bottlenecks code src
bottlenecks history diff --fail-on high                # CI regression gate
bottlenecks plan schedule "code.scan path=src" --every 1h && bottlenecks plan run-due
bottlenecks urtlog ~/.local/share/urtlog              # bottlenecks in any urtlog event log

# other interfaces, same engine
bottlenecks serve-rest --port 8765   # POST /dsl, POST /query, GET /suggest, /schema, /history
bottlenecks serve-mcp                # tools: nl_ask, execute_dsl, suggest_options, list_actions
bottlenecks self-test                # 12 conformance checks

Integration with urtlog and an LLM

  • If URTLOG_STATE_DIR is set and uritime-urtlog is importable, every record is also mirrored into that urtlog store. Mirroring is fail-soft. You can then use urtlog query --source bottlenecks and urtlog logic-tree --op-prefix op/proc/bottlenecks/.
  • The LLM fallback (Layer 3) is off by default. To enable it, set BOTTLENECKS_LLM_URL (any OpenAI-compatible /v1, e.g. Ollama or OpenRouter), BOTTLENECKS_LLM_MODEL and optionally BOTTLENECKS_LLM_API_KEY. Its output is JSON-schema constrained and validated against the registry, and successful answers are learned into the semantic cache.

Python API

from bottlenecks import Engine, Ledger, analyze_code, render

engine = Engine(ledger=Ledger(".bottlenecks"))
res = engine.ask("znajdź wąskie gardła w kodzie src")      # or engine.execute("code.scan path=src")
print(res.meta["canonicalDsl"], res.meta["urtlog"])
print(render(res.report, "text"))

print(render(analyze_code("src/"), "markdown"))            # analyzers are still plain functions

License

Apache-2.0 © Tom Sapletta

Metadata

Release files for bottlenecks 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bottlenecks 0.2.0
File Size Uploaded Provenance Actions
bottlenecks-0.2.0.tar.gz 72.4 kB Without provenance Details for bottlenecks-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bottlenecks 0.2.0
File Interpreter ABI Platform Actions
bottlenecks-0.2.0-py3-none-any.whl Python 3 none any Details for bottlenecks-0.2.0-py3-none-any.whl

Total release size: 145.5 kB

Release files / bottlenecks-0.2.0.tar.gz

Download URL bottlenecks-0.2.0.tar.gz
Size 72.4 kB
Tags Source
SHA-256 checksum
How to use checksums
726351a809a6b9d4be480af544f834b3c00f17cb505977b3bbdc3a4d3afda999
BLAKE2b-256 checksum
How to use checksums
0e53c86180500d7a5028443447ea8e403ab6312de50a06c41042add83fe6327d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / bottlenecks-0.2.0-py3-none-any.whl

Download URL bottlenecks-0.2.0-py3-none-any.whl
Size 73.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5fc2cec97e7588a1052b35158fe3aac565937d53a20ec2073a602a3560909623
BLAKE2b-256 checksum
How to use checksums
4f4c2ce6b7318c4f71d91cfa41853cb551c0e0736ad42e2af180d6a8dbb92964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Security for bottlenecks 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page