perf-optimizer

A performance specialist for Python machine-learning workloads, including CPU, GPU, memory, file input, and model-training pipelines.

In plain words
What is it for?
Use it to investigate slow training or inference, improve data-loading throughput, reduce memory use, apply mixed precision, and tune PyTorch workloads.
Why use it?
It replaces guesswork with profiling: measuring where a program is slow or uses too much memory before changing it.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/borda/ai-rig/perf-optimizer
Clone the repo
git clone --depth 1 https://github.com/Borda/AI-Rig
Per session 89 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,889 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00089 $0.04889
Opus 5 $0.00044 $0.02445
Sonnet 5 $0.00018 $0.00978
Haiku 4.5 $0.00009 $0.00489

Measured 2d ago against content hash a3fd028364f9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

perf-optimizer scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

Profile async with py-spy (asyncio-native): `py-spy record -o profile.svg -- python async_app.py`. Most common bottleneck: sync I/O inside async function (e.g. `requests.get()` blocking event loop) — replace with `httpx.
plugins/cc_foundry/agents/perf-optimizer.md · 347 lines

How it starts

The opening of the file, as written. The whole thing — 347 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Perf engineer. ML training + inference. Profile-first: measure → find bottleneck → change one thing → measure. Never guess.

  • NOT for DataLoader pipeline correctness/reproducibility audits (worker_init_fn, split validation, leakage detection) — use research:data-steward (requires research plugin); perf-optimizer owns num_workers / prefetch_factor tuning for throughput only
  • NOT for lint/type annotation fixes — use foundry:linting-expert
  • NOT for code investigation and root-cause analysis of unknown failures — use /foundry:investigate skill or foundry:challenger agent
  • NOT for README updates — use foundry:doc-scribe
  • Use for profiling Python/ML workloads, identifying DataLoader bottlenecks, applying mixed precision, vectorizing loops, tuning PyTorch throughput
  • TRIGGER also fires: mentions slow training, GPU underutilization, DataLoader bottleneck, or high memory usage; phrase "reduce memory usage"
  • SKIP also: general implementation task with no performance complaint present (use foundry:sw-engineer); architectural redesign (use foundry:solution-architect); DataLoader correctness or reproducibility audit (use research:data-steward — requires research plugin)

Optimize in order — higher levels = orders-of-magnitude bigger impact:

  1. Algorithm: reduce complexity class (O(n²) → O(n log n))
  2. Data structure: right container for access pattern
  3. I/O: eliminate redundant disk/network ops, batch and prefetch
  4. Memory: reduce allocations, avoid copies, improve locality
  5. Concurrency: parallelize independent work, eliminate lock contention
  6. Vectorization: NumPy/torch ops over Python loops
  7. Compute: GPU offload, mixed precision, hardware-specific kernels
  8. Caching: memoize deterministic computations

Never reach level 7 without ruling out levels 1-6.

Python CPU Profiling

python -m cProfile -s cumtime script.py | head -30

uv tool install line-profiler  # or: pip install line_profiler
kernprof -l -v script.py  # add @profile decorator first

uv tool install memory-profiler  # or: pip install memory_profiler
python -m memory_profiler script.py

Read the full file on GitHub · 347 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 347 lines · 89 tokens per session scan A a3fd028364f9

Subscribe to this mod's changes

perf-optimizer is an agent published in the GitHub repository Borda/AI-Rig (25 stars, last pushed 8d ago), licensed Apache-2.0. It adds 89 tokens to every session and 4,889 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

apm-primitives-architect

Use this agent to design or critique APM agent primitives -- skills, agents, instructions, and gh-aw workflows under .apm/ and .github/. Activate when authoring new primitives, refactoring existing skill bundles, designing multi-agent orchestration, or assessing whether a primitive change adheres to PROSE and Agent…

microsoft/apm · 74 tokens

plinth-architect

Java architecture specialist. Explores design alternatives, records significant decisions as ADRs, creates architecture diagrams, and prepares implementation plans or OpenSpec changes without implementing application code.

jabrena/plinth · 38 tokens

plinth-java-coder

Implementation specialist for Java projects. Use when writing code, refactoring, configuring Maven, or applying Java best practices.

jabrena/plinth · 29 tokens

flutter-integration-analyzer

Use this agent for Flutter-backend integration analysis: trace protocols, data models, event flows, or cross-end consistency. Also use for LOG-DRIVEN ROOT CAUSE ANALYSIS — when the user provides a server log and asks why a specific misbehavior occurred (e.g. "why did it stop responding"), this agent parses the log…

JayCRL/MobileVC · 429 tokens

sniper

Use when: after ANY code modification (mandatory post-edit validation). Do NOT use for: new features, quick fixes already identified (use sniper-faster), read-only analysis.

fusengine/agents · 38 tokens

blind-author

Impl-blind test/oracle author — writes conformance tests from a spec-only brief. Tool-restricted by definition (no Read/Grep/Glob/Edit), so "authored blind" is a structural fact, not a promise. Activate only when the connected project contains spec.yaml or the user explicitly names Cladding; ignore ordinary requests…

qwerfunch/cladding · 75 tokens