mcpField
P
performance-engineer

performance-engineer

github.com/zhaono1開発85712 回インストール10 週間前に更新
リポジトリ

performance-engineer について

アプリケーションの遅延を調査し、効率を改善する開発者向けスキルです。計測とプロファイリングから、ボトルネックの特定、最適化、検証までを案内します。

主な機能

  1. 01指標の基準値設定とプロファイリング
  2. 02アプリケーション各層のボトルネック分析
  3. 03データベース、API、フロントエンドの最適化
  4. 04変更後のパフォーマンス検証
  5. 05プロファイルとレポートのスクリプト

活用シーン

  1. 01API応答の遅延調査
  2. 02データベースクエリのボトルネック特定
  3. 03フロントエンドの読み込み遅延の削減
  4. 04最適化後の性能低下の確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/zhaono1/agent-playbook --skill performance-engineer

インストール後、Claude Code で/performance-engineerを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

README.md
references/
checklist.md
monitoring.md
optimization.md
scripts/
perf_report.py
profile.py

詳細

パフォーマンスエンジニア

アプリケーションのパフォーマンスを分析・最適化し、ボトルネックを特定して効率を改善する専門家です。

このスキルが有効になるとき

以下の場合に有効になります:

  • パフォーマンスの問題を報告したとき
  • パフォーマンスを最適化する必要があるとき
  • 「遅い」や「レイテンシ」に言及したとき
  • 効率を改善したいとき

パフォーマンス分析のプロセス

フェーズ 1:問題の特定
  1. 指標を定義する

    • ベースラインはどのくらいですか?
    • 目標はどのくらいですか?
    • 許容範囲はどのくらいですか?
  2. 現在のパフォーマンスを測定する

    # Response time
    curl -w "@curl-format.txt" -o /dev/null -s https://example.com/users
    
    # Database query time
    # Add timing logs to queries
    
    # Memory usage
    # Use profiler
    
  3. アプリケーションをプロファイリングする

    # Node.js
    node --prof app.js
    
    # Python
    python -m cProfile app.py
    
    # Go
    go test -cpuprofile=cpu.prof
    
フェーズ 2:ボトルネックの特定

よくあるボトルネックの箇所:

レイヤーよくある問題
データベースN+1 クエリ、インデックスの欠如、大規模な結果セット
API過剰なデータ取得、キャッシュなし、直列リクエスト
アプリケーション非効率なアルゴリズム、過剰なログ出力
フロントエンド大きなバンドル、再レンダリング、遅延読み込みなし
ネットワークリクエスト数の多さ、大きなペイロード、圧縮なし
フェーズ 3:最適化
データベースの最適化

N+1 クエリ:

// Bad: N+1 queries
const users = await User.findAll();
for (const user of users) {
  user.posts = await Post.findAll({ where: { userId: user.id } });
}

// Good: Eager loading
const users = await User.findAll({
  include: [{ model: Post, as: 'posts' }]
});

インデックスの欠如:

-- Add index on frequently queried columns
CREATE INDEX idx_user_email ON users(email);
CREATE INDEX idx_post_user_id ON posts(user_id);
API の最適化

ページネーション:

// Always paginate large result sets
const users = await User.findAll({
  limit: 100,
  offset: page * 100
});

フィールド選択:

// Select only needed fields
const users = await User.findAll({
  attributes: ['id', 'name', 'email']
});

圧縮:

// Enable gzip compression
app.use(compression());
フロントエンドの最適化

コード分割:

// Lazy load routes
const Dashboard = lazy(() => import('./Dashboard'));

メモ化:

// Use useMemo for expensive calculations
const filtered = useMemo(() =>
  items.filter(item => item.active),
  [items]
);

画像の最適化:

  • WebP 形式を使用する
  • 画像を遅延読み込みする
  • レスポンシブ画像を使用する
  • 画像を圧縮する
フェーズ 4:検証
  1. 再度測定する
  2. ベースラインと比較する
  3. デグレードがないことを確認する
  4. 改善内容を記録する

パフォーマンス目標

サービスの SLO、現在のベースライン、ワークロードの特性、コスト予算、重要なユーザージャーニーをもとに目標を設定してください。以下の表は出発点の一例にすぎません。根拠や担当者の合意がないまま、システムの受け入れ基準として示さないでください。

指標目標重大な閾値
API 応答(p50)< 100ms< 500ms
API 応答(p95)< 500ms< 1s
API 応答(p99)< 1s< 2s
データベースクエリ< 50ms< 200ms
ページ読み込み(FMP)< 2s< 3s
インタラクティブになるまでの時間< 3s< 5s
メモリ使用量< 512MB< 1GB

よくある最適化

キャッシュ戦略
// Cache expensive computations
const cache = new Map();

async function getUserStats(userId: string) {
  if (cache.has(userId)) {
    return cache.get(userId);
  }

  const stats = await calculateUserStats(userId);
  cache.set(userId, stats);

  // Invalidate after 5 minutes
  setTimeout(() => cache.delete(userId), 5 * 60 * 1000);

  return stats;
}
バッチ処理
// Bad: Individual requests
for (const id of userIds) {
  await fetchUser(id);
}

// Good: Batch request
await fetchUsers(userIds);
デバウンス/スロットリング
// Debounce search input
const debouncedSearch = debounce(search, 300);

// Throttle scroll events
const throttledScroll = throttle(handleScroll, 100);

パフォーマンスの監視

主な指標
  • 応答時間:リクエストの処理にかかる時間
  • スループット:1 秒あたりのリクエスト数
  • エラー率:失敗したリクエストの割合
  • メモリ使用量:使用中のヒープ/RAM
  • CPU 使用率:プロセッサーの使用率
監視ツール
ツール用途
Lighthouseフロントエンドのパフォーマンス
New RelicAPM の監視
Datadogインフラストラクチャの監視
Prometheus指標の収集

スクリプト

アプリケーションをプロファイリングする:

python3 scripts/profile.py --name <service-name> --output perf-profile.txt

パフォーマンスレポートを生成する:

python3 scripts/perf_report.py --name <service-name> --output perf-report.md

参考資料

  • references/optimization.md - 最適化手法
  • references/monitoring.md - 監視の設定
  • references/checklist.md - パフォーマンスチェックリスト

コメント