‹ 首页

perf

@oliver-kriska · 收录于 4 天前 · 上游提交 4 天前

Analyze Elixir/Phoenix performance — N+1 queries, assign bloat, ecto optimization, genserver bottlenecks. Use when slowness, timeouts, or high memory reported.

适合你,如果需要诊断 Elixir/Phoenix 应用的性能问题,定位慢查询和瓶颈

/ 通过 npx 安装 校验哈希
npx oh-my-skill add oliver-kriska/claude-elixir-phoenix/perf
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- oliver-kriska/claude-elixir-phoenix/perf
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify oliver-kriska/claude-elixir-phoenix/perf
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
503GitHub stars
~817最小装载
~817含声明引用
~2K文本包总量
索引托管

怎么用

商店整理自技能原文 · 版本 88c1194 · 表述以原文为准
它做什么

装上后,Claude 会分析 Elixir/Phoenix 代码的性能问题,查找 N+1 查询、assign 膨胀、Ecto 优化和 GenServer 瓶颈,按影响和努力排序给出前 5 个发现,并提供后续操作建议。

什么时候触发

当你报告系统变慢、超时或内存占用高时,使用 /phx:perf 命令触发。也可指定模块或 --focus 参数聚焦特定层面。

装好后可以这样说
Claude 会扫描所有文件,找出瓶颈并排序。
Claude 只分析指定模块的错误。
Claude 专注 Ecto 相关优化。
技能原文 SKILL.md作者撰写 · MIT · 88c1194

Performance Analysis

Analyze code for performance issues across Ecto, LiveView, and OTP layers. Prioritize findings by impact and effort.

Usage
/phx:perf                           # Analyze full project
/phx:perf lib/my_app/accounts.ex    # Analyze specific module
/phx:perf --focus ecto              # Ecto queries only
/phx:perf --focus liveview          # LiveView memory only
/phx:perf --focus otp               # OTP bottlenecks only
Arguments

$ARGUMENTS = Optional module/context path and --focus flag.

Iron Laws
  1. MEASURE BEFORE OPTIMIZING — Never optimize without evidence of a problem
  2. DATABASE FIRST — 90% of Elixir performance issues are query-related
  3. ONE CHANGE AT A TIME — Isolate optimizations to measure impact
  4. NEVER benchmark in dev mode — Always use MIX_ENV=prod for performance measurements; dev mode includes code reloading, debug logging, and unoptimized compilation that invalidate results
Workflow
Step 1: Identify Scope

Check specific file if provided. Otherwise scan full project:

# Find hot paths: contexts, LiveViews, workers
find lib/ -name "*.ex" | head -50
Step 2: Run Analysis Tracks

Spawn analysis agents in parallel based on focus:

Ecto Track (default or --focus ecto):

Spawn phx:elixir-reviewer with prompt: "Analyze for N+1 queries, missing preloads, unindexed queries, and inefficient patterns. Check: Repo.all in loops, Enum.map with Repo calls, missing preload, queries without indexes on WHERE/JOIN columns."

LiveView Track (default or --focus liveview):

Spawn phx:elixir-reviewer with prompt: "Analyze LiveViews for memory issues: large assigns, missing streams for lists, assigns that grow unbounded, heavy handle_info processing, missing assign_async for slow ops."

OTP Track (only with --focus otp):

Spawn phx:otp-advisor with prompt: "Analyze for OTP bottlenecks: GenServer mailbox growth, synchronous calls in hot paths, missing Task.async for parallel work, ETS opportunities for read-heavy state."

Step 3: Prioritize Findings

Score each finding on a 2x2 matrix:

| | Low Effort | High Effort | |---|---|---| | High Impact | DO FIRST | PLAN | | Low Impact | QUICK WIN | SKIP |

High impact = affects response time, memory per user, or query count. Low effort = single file change, no migration needed.

Step 4: Present Top 5

Present findings sorted by priority:

## Performance Analysis: {scope}

### 1. {Finding} — DO FIRST
**Impact**: {what improves}
**Location**: {file}:{line}
**Current**: {problematic pattern}
**Fix**: {optimized pattern}
**Estimated gain**: {e.g., "eliminates N+1, reduces queries from O(n) to O(1)"}

### 2. {Finding} — PLAN
...
Step 5: Offer Next Steps

Always end with actionable next steps — findings without follow-up get lost. Present options based on severity:

How would you like to proceed?

- `/phx:plan` — Create a plan from these findings (recommended for 3+ fixes)
- `/phx:quick` — Apply top priority fix directly (1-2 simple fixes)
- `/phx:investigate` — Deep-dive into a specific finding
Tidewave Integration

If Tidewave MCP is available:

  • Use mcp__tidewave__project_eval to run Repo.query!("EXPLAIN ANALYZE ...") on suspicious queries
  • Use mcp__tidewave__project_eval to check Process.info(pid, :message_queue_len) for GenServer bottlenecks
  • Use mcp__tidewave__execute_sql_query to check missing indexes
References
  • ${CLAUDE_SKILL_DIR}/references/benchmarking.md — Benchee patterns, profiling, flame graphs
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。