jpskill.com
📦 その他 コミュニティ

when-profiling-performance-use-performance-profiler

包括的なパフォーマンスプロファイリングによってボトルネックを検出し、システム全体の最適化を図ることで、より効率的なシステム運用を実現するSkill。

📜 元の英語説明(参考)

Comprehensive performance profiling, bottleneck detection, and optimization system

🇯🇵 日本人クリエイター向け解説

一言でいうと

包括的なパフォーマンスプロファイリングによってボトルネックを検出し、システム全体の最適化を図ることで、より効率的なシステム運用を実現するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o when-profiling-performance-use-performance-profiler.zip https://jpskill.com/download/18814.zip && unzip -o when-profiling-performance-use-performance-profiler.zip && rm when-profiling-performance-use-performance-profiler.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18814.zip -OutFile "$d\when-profiling-performance-use-performance-profiler.zip"; Expand-Archive "$d\when-profiling-performance-use-performance-profiler.zip" -DestinationPath $d -Force; ri "$d\when-profiling-performance-use-performance-profiler.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して when-profiling-performance-use-performance-profiler.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → when-profiling-performance-use-performance-profiler フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
2

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

パフォーマンスプロファイラースキル

概要

パフォーマンスプロファイリングを行う際は、performance-profiler を使用して CPU、メモリ、I/O、ネットワークの各側面でアプリケーションのパフォーマンスを測定、分析、最適化します。

MECE 分解

相互排他的なコンポーネント:

  1. ベースラインフェーズ: 現在のパフォーマンスメトリクスを確立します
  2. 検出フェーズ: ボトルネックとホットパスを特定します
  3. 分析フェーズ: 根本原因分析と影響評価を行います
  4. 最適化フェーズ: 推奨事項を生成し、優先順位を付けます
  5. 実装フェーズ: エージェントの支援を受けて最適化を適用します
  6. 検証フェーズ: 改善点をベンチマークし、効果を確認します

包括的なカバレッジ:

  • CPU プロファイリング: 関数実行時間、ホットパス、コールグラフ
  • メモリプロファイリング: ヒープ使用量、割り当て、リーク、ガベージコレクション
  • I/O プロファイリング: ファイルシステム、データベース、ネットワークレイテンシー
  • ネットワークプロファイリング: リクエストタイミング、帯域幅、コネクションプーリング
  • 並行処理: スレッド利用率、ロック競合、非同期操作
  • アルゴリズム分析: 時間計算量、空間計算量
  • キャッシュ分析: ヒット率、キャッシュミス、無効化パターン
  • データベース: クエリパフォーマンス、N+1 問題、インデックス使用

機能

コア機能:

  • 多次元パフォーマンスプロファイリング (CPU、メモリ、I/O、ネットワーク)
  • 優先順位付けされた自動ボトルネック検出
  • リアルタイムプロファイリングと履歴分析
  • 視覚分析のためのフレームグラフ生成
  • メモリリーク検出とヒープスナップショット
  • データベースクエリ最適化
  • アルゴリズムの複雑性分析
  • 最適化前後の A/B 比較
  • オーバーヘッドを最小限に抑えた本番環境対応のプロファイリング
  • APM ツール (New Relic、DataDog など) との統合

プロファイリングモード:

  • Quick Scan: 30秒の軽量プロファイリング
  • Standard: 5分間の包括的な分析
  • Deep: 30分間の詳細な調査
  • Continuous: 長時間実行される本番環境監視
  • Stress Test: 高トラフィック下での負荷ベースのプロファイリング

使用方法

スラッシュコマンド:

/profile [path] [--mode quick|standard|deep] [--target cpu|memory|io|network|all]

サブエージェント呼び出し:

Task("Performance Profiler", "Profile ./app with deep CPU and memory analysis", "performance-analyzer")

MCP ツール:

mcp__performance-profiler__analyze({
  project_path: "./app",
  profiling_mode: "standard",
  targets: ["cpu", "memory", "io"],
  generate_optimizations: true
})

アーキテクチャ

フェーズ 1: ベースライン測定

  1. 現在のパフォーマンスメトリクスを確立します
  2. パフォーマンス予算を定義します
  3. 監視インフラストラクチャをセットアップします
  4. ベースラインスナップショットをキャプチャします

フェーズ 2: ボトルネック検出

  1. CPU プロファイリング (サンプリングまたはインストルメンテーション)
  2. メモリプロファイリング (ヒープ分析)
  3. I/O プロファイリング (システムコールトレース)
  4. ネットワークプロファイリング (パケット分析)
  5. データベースプロファイリング (クエリログ)

フェーズ 3: 根本原因分析

  1. 複数の側面でメトリクスを相関させます
  2. 因果関係を特定します
  3. パフォーマンスへの影響を計算します
  4. 重大度別に問題を優先順位付けします

フェーズ 4: 最適化生成

  1. アルゴリズムの改善
  2. キャッシュ戦略
  3. 並列化の機会
  4. データベースクエリ最適化
  5. メモリ最適化
  6. ネットワーク最適化

フェーズ 5: 実装

  1. コーダーエージェントで最適化されたコードを生成します
  2. データベース最適化を適用します
  3. キャッシュ層を設定します
  4. 並列化を実装します

フェーズ 6: 検証

  1. ベンチマークスイートを実行します
  2. 最適化前後のメトリクスを比較します
  3. 回帰がないことを確認します
  4. パフォーマンスレポートを生成します

出力形式

パフォーマンスレポート:

{
  "project": "my-app",
  "profiling_mode": "standard",
  "duration_seconds": 300,
  "baseline": {
    "requests_per_second": 1247,
    "avg_response_time_ms": 123,
    "p95_response_time_ms": 456,
    "p99_response_time_ms": 789,
    "cpu_usage_percent": 67,
    "memory_usage_mb": 512,
    "error_rate_percent": 0.1
  },
  "bottlenecks": [
    {
      "type": "cpu",
      "severity": "high",
      "function": "processData",
      "time_percent": 34.5,
      "calls": 123456,
      "avg_time_ms": 2.3,
      "recommendation": "Optimize algorithm complexity from O(n²) to O(n log n)"
    }
  ],
  "optimizations": [...],
  "estimated_improvement": {
    "throughput_increase": "3.2x",
    "latency_reduction": "68%",
    "memory_reduction": "45%"
  }
}

フレームグラフ:

時間比率を示すコールスタックのインタラクティブな SVG フレームグラフ

ヒープスナップショット:

保持パスを含むメモリ割り当ての内訳

最適化レポート:

コード例を含む、実行可能な改善点の優先順位付けされたリスト

例 1: クイック CPU プロファイリング

/profile ./my-app --mode quick --target cpu

例 2: ディープメモリ分析

/profile ./my-app --mode deep --target memory --detect-leaks

例 3: フルスタック最適化

/profile ./my-app --mode standard --target all --optimize --benchmark

例 4: データベースクエリ最適化

/profile ./my-app --mode standard --target io --database --explain-queries

Claude-Flow との統合

連携パターン:


// ステップ 1: プロファイリングスウォームを初期化します
mcp__claude-flow__swarm_init({ topology: "star", maxAgents: 5 })

// ステップ 2: 特殊なエージェントを生成します
[並列実行]:
  Task("CPU Profiler", "Profile CPU usage and identify hot paths in ./app", "performance-analyzer")
  Task("Memory Profiler", "Analyze heap usage and detect memory leaks", "performance-analyzer")
  Task("I/O Profiler", "Profile file system and database operations", "performance-analyzer")
  Task("Network Profiler", "Analyze network requests and identify slow endpoints", "performance-analyzer")
  Task("Optimizer", "Generate optimization recommendations based on profiling data", "optimizer")

// ステップ 3: 実装エージェントが最適化を適用します
[順次実行]:
  Task("Coder", "Implement recommended optimizations from profiling analysis", "coder")
  Task("Ben

(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Performance Profiler Skill

Overview

When profiling performance, use performance-profiler to measure, analyze, and optimize application performance across CPU, memory, I/O, and network dimensions.

MECE Breakdown

Mutually Exclusive Components:

  1. Baseline Phase: Establish current performance metrics
  2. Detection Phase: Identify bottlenecks and hot paths
  3. Analysis Phase: Root cause analysis and impact assessment
  4. Optimization Phase: Generate and prioritize recommendations
  5. Implementation Phase: Apply optimizations with agent assistance
  6. Validation Phase: Benchmark improvements and verify gains

Collectively Exhaustive Coverage:

  • CPU Profiling: Function execution time, hot paths, call graphs
  • Memory Profiling: Heap usage, allocations, leaks, garbage collection
  • I/O Profiling: File system, database, network latency
  • Network Profiling: Request timing, bandwidth, connection pooling
  • Concurrency: Thread utilization, lock contention, async operations
  • Algorithm Analysis: Time complexity, space complexity
  • Cache Analysis: Hit rates, cache misses, invalidation patterns
  • Database: Query performance, N+1 problems, index usage

Features

Core Capabilities:

  • Multi-dimensional performance profiling (CPU, memory, I/O, network)
  • Automated bottleneck detection with prioritization
  • Real-time profiling and historical analysis
  • Flame graph generation for visual analysis
  • Memory leak detection and heap snapshots
  • Database query optimization
  • Algorithmic complexity analysis
  • A/B comparison of before/after optimizations
  • Production-safe profiling with minimal overhead
  • Integration with APM tools (New Relic, DataDog, etc.)

Profiling Modes:

  • Quick Scan: 30-second lightweight profiling
  • Standard: 5-minute comprehensive analysis
  • Deep: 30-minute detailed investigation
  • Continuous: Long-running production monitoring
  • Stress Test: Load-based profiling under high traffic

Usage

Slash Command:

/profile [path] [--mode quick|standard|deep] [--target cpu|memory|io|network|all]

Subagent Invocation:

Task("Performance Profiler", "Profile ./app with deep CPU and memory analysis", "performance-analyzer")

MCP Tool:

mcp__performance-profiler__analyze({
  project_path: "./app",
  profiling_mode: "standard",
  targets: ["cpu", "memory", "io"],
  generate_optimizations: true
})

Architecture

Phase 1: Baseline Measurement

  1. Establish current performance metrics
  2. Define performance budgets
  3. Set up monitoring infrastructure
  4. Capture baseline snapshots

Phase 2: Bottleneck Detection

  1. CPU profiling (sampling or instrumentation)
  2. Memory profiling (heap analysis)
  3. I/O profiling (syscall tracing)
  4. Network profiling (packet analysis)
  5. Database profiling (query logs)

Phase 3: Root Cause Analysis

  1. Correlate metrics across dimensions
  2. Identify causal relationships
  3. Calculate performance impact
  4. Prioritize issues by severity

Phase 4: Optimization Generation

  1. Algorithmic improvements
  2. Caching strategies
  3. Parallelization opportunities
  4. Database query optimization
  5. Memory optimization
  6. Network optimization

Phase 5: Implementation

  1. Generate optimized code with coder agent
  2. Apply database optimizations
  3. Configure caching layers
  4. Implement parallelization

Phase 6: Validation

  1. Run benchmark suite
  2. Compare before/after metrics
  3. Verify no regressions
  4. Generate performance report

Output Formats

Performance Report:

{
  "project": "my-app",
  "profiling_mode": "standard",
  "duration_seconds": 300,
  "baseline": {
    "requests_per_second": 1247,
    "avg_response_time_ms": 123,
    "p95_response_time_ms": 456,
    "p99_response_time_ms": 789,
    "cpu_usage_percent": 67,
    "memory_usage_mb": 512,
    "error_rate_percent": 0.1
  },
  "bottlenecks": [
    {
      "type": "cpu",
      "severity": "high",
      "function": "processData",
      "time_percent": 34.5,
      "calls": 123456,
      "avg_time_ms": 2.3,
      "recommendation": "Optimize algorithm complexity from O(n²) to O(n log n)"
    }
  ],
  "optimizations": [...],
  "estimated_improvement": {
    "throughput_increase": "3.2x",
    "latency_reduction": "68%",
    "memory_reduction": "45%"
  }
}

Flame Graph:

Interactive SVG flame graph showing call stack with time proportions

Heap Snapshot:

Memory allocation breakdown with retention paths

Optimization Report:

Prioritized list of actionable improvements with code examples

Examples

Example 1: Quick CPU Profiling

/profile ./my-app --mode quick --target cpu

Example 2: Deep Memory Analysis

/profile ./my-app --mode deep --target memory --detect-leaks

Example 3: Full Stack Optimization

/profile ./my-app --mode standard --target all --optimize --benchmark

Example 4: Database Query Optimization

/profile ./my-app --mode standard --target io --database --explain-queries

Integration with Claude-Flow

Coordination Pattern:

// Step 1: Initialize profiling swarm
mcp__claude-flow__swarm_init({ topology: "star", maxAgents: 5 })

// Step 2: Spawn specialized agents
[Parallel Execution]:
  Task("CPU Profiler", "Profile CPU usage and identify hot paths in ./app", "performance-analyzer")
  Task("Memory Profiler", "Analyze heap usage and detect memory leaks", "performance-analyzer")
  Task("I/O Profiler", "Profile file system and database operations", "performance-analyzer")
  Task("Network Profiler", "Analyze network requests and identify slow endpoints", "performance-analyzer")
  Task("Optimizer", "Generate optimization recommendations based on profiling data", "optimizer")

// Step 3: Implementation agent applies optimizations
[Sequential Execution]:
  Task("Coder", "Implement recommended optimizations from profiling analysis", "coder")
  Task("Benchmarker", "Run benchmark suite and validate improvements", "performance-benchmarker")

Configuration

Default Settings:

{
  "profiling": {
    "sampling_rate_hz": 99,
    "stack_depth": 128,
    "include_native_code": false,
    "track_allocations": true
  },
  "thresholds": {
    "cpu_hot_path_percent": 10,
    "memory_leak_growth_mb": 10,
    "slow_query_ms": 100,
    "slow_request_ms": 1000
  },
  "optimization": {
    "auto_apply": false,
    "require_approval": true,
    "run_tests_before": true,
    "run_benchmarks_after": true
  },
  "output": {
    "flame_graph": true,
    "heap_snapshot": true,
    "call_tree": true,
    "recommendations": true
  }
}

Profiling Techniques

CPU Profiling:

  • Sampling: Periodic stack sampling (low overhead)
  • Instrumentation: Function entry/exit hooks (accurate but higher overhead)
  • Tracing: Event-based profiling

Memory Profiling:

  • Heap Snapshots: Point-in-time memory state
  • Allocation Tracking: Record all allocations
  • Leak Detection: Compare snapshots over time
  • GC Analysis: Garbage collection patterns

I/O Profiling:

  • Syscall Tracing: Track system calls (strace, dtrace)
  • File System: Monitor read/write operations
  • Database: Query logging and EXPLAIN ANALYZE
  • Network: Packet capture and request timing

Concurrency Profiling:

  • Thread Analysis: CPU utilization per thread
  • Lock Contention: Identify blocking operations
  • Async Operations: Promise/callback timing

Performance Optimization Strategies

Algorithmic:

  • Reduce time complexity (O(n²) → O(n log n))
  • Use appropriate data structures
  • Eliminate unnecessary work
  • Memoization and dynamic programming

Caching:

  • In-memory caching (Redis, Memcached)
  • CDN for static assets
  • HTTP caching headers
  • Query result caching

Parallelization:

  • Multi-threading
  • Worker pools
  • Async I/O
  • Batching operations

Database:

  • Add missing indexes
  • Optimize queries
  • Reduce N+1 queries
  • Connection pooling
  • Read replicas

Memory:

  • Object pooling
  • Reduce allocations
  • Stream processing
  • Compression

Network:

  • Connection keep-alive
  • HTTP/2 or HTTP/3
  • Compression
  • Request batching
  • Rate limiting

Performance Budgets

Frontend:

  • Time to First Byte (TTFB): < 200ms
  • First Contentful Paint (FCP): < 1.8s
  • Largest Contentful Paint (LCP): < 2.5s
  • Time to Interactive (TTI): < 3.8s
  • Total Blocking Time (TBT): < 200ms
  • Cumulative Layout Shift (CLS): < 0.1

Backend:

  • API Response Time (p50): < 100ms
  • API Response Time (p95): < 500ms
  • API Response Time (p99): < 1000ms
  • Throughput: > 1000 req/s
  • Error Rate: < 0.1%
  • CPU Usage: < 70%
  • Memory Usage: < 80%

Database:

  • Query Time (p50): < 10ms
  • Query Time (p95): < 50ms
  • Query Time (p99): < 100ms
  • Connection Pool Utilization: < 80%

Best Practices

  1. Profile production workloads when possible
  2. Use production-like data volumes
  3. Profile under realistic load
  4. Measure multiple times for consistency
  5. Focus on p95/p99, not just averages
  6. Optimize bottlenecks in order of impact
  7. Always benchmark before and after
  8. Monitor for regressions in CI/CD
  9. Set up continuous profiling
  10. Track performance over time

Troubleshooting

Issue: High CPU usage but no obvious hot path

Solution: Check for excessive small function calls, increase sampling rate, or use instrumentation

Issue: Memory grows continuously

Solution: Run heap snapshot comparison to identify leak sources

Issue: Slow database queries

Solution: Use EXPLAIN ANALYZE, check for missing indexes, analyze query plans

Issue: High latency but low CPU

Solution: Profile I/O operations, check for blocking synchronous calls

See Also

  • PROCESS.md - Detailed step-by-step profiling workflow
  • README.md - Quick start guide
  • subagent-performance-profiler.md - Agent implementation details
  • slash-command-profile.sh - Command-line interface
  • mcp-performance-profiler.json - MCP tool schema

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。