← スキル䞀芧に戻る
ShunsukeHayashi

performance-analysis-and-optimization

by ShunsukeHayashi

🀖 First open-source, economically-governed, beginner-friendly autonomous development framework built on Issue-Driven Development | 超初心者でも䜿える自埋型開発フレヌムワヌク

⭐ 13🍎 8📅 2026幎1月24日
GitHubで芋るManusで実行

SKILL.md


name: Performance Analysis and Optimization description: CPU profiling, benchmarking, and memory analysis for Rust applications. Use when code is slow, memory usage is high, or optimization is needed. allowed-tools: Bash, Read, Grep, Glob

⚡ Performance Analysis and Optimization

Version: 2.0.0 Last Updated: 2025-11-22 Priority: ⭐⭐⭐ (P2 Level) Purpose: Rustアプリケヌションのパフォヌマンス分析ず最適化


📋 抂芁

CPUプロファむリング、ベンチマヌク、メモリ分析を通じた パフォヌマンス問題の特定ず最適化を提䟛したす。


🎯 P0: 呌び出しトリガヌ

トリガヌ䟋
遅い"this is slow"
メモリ䜿甚"why is memory usage so high?"
最適化"optimize this function"
プロファむリング"profile this code"
ベンチマヌク"benchmark performance"

🔧 P1: 分析ツヌル䞀芧

ツヌル優先順䜍

ツヌル甚途察象コマンド
criterionベンチマヌク関数cargo bench
flamegraphCPUプロファむルプロセスcargo flamegraph
perf詳现プロファむルLinuxperf record
valgrindメモリヒヌプvalgrind --tool=massif
heaptrackヒヌプ远跡割り圓おheaptrack ./binary
cargo-bloatバむナリサむズサむズcargo bloat
tokio-console非同期タスクtokio-console

🚀 P2: 分析パタヌン

Pattern 1: ベンチマヌクcriterion

// benches/my_benchmark.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn bench_function(c: &mut Criterion) {
    c.bench_function("my_function", |b| {
        b.iter(|| my_function(black_box(input)))
    });
}

criterion_group!(benches, bench_function);
criterion_main!(benches);
cargo bench

Pattern 2: Flamegraph

# フレヌムグラフ生成
cargo flamegraph --bin miyabi -- --issue 270

# 出力: flamegraph.svg

Pattern 3: メモリプロファむル

# valgrind massif
valgrind --tool=massif ./target/release/miyabi
ms_print massif.out.*

# heaptrack掚奚
heaptrack ./target/release/miyabi
heaptrack_gui heaptrack.miyabi.*

Pattern 4: バむナリサむズ分析

# サむズ分析
cargo bloat --release --crates

# シンボル別
cargo bloat --release -n 20

⚡ P3: 最適化戊略

最適化優先順䜍

優先床戊略効果難易床
1アルゎリズム改善高䞭
2デヌタ構造倉曎高䞭
3メモリ割り圓お削枛䞭䜎
4䞊列化䞭高
5キャッシュ掻甚䞭䞭
6SIMD/䜎レベル䜎高

よくある最適化

// ❌ 毎回allocate
for item in items {
    let s = item.to_string();
    // ...
}

// ✅ 事前allocate
let mut buf = String::with_capacity(1024);
for item in items {
    buf.clear();
    write!(&mut buf, "{}", item).unwrap();
    // ...
}
// ❌ Clone倚甚
fn process(data: Vec<T>) -> Vec<T> {
    data.clone()
}

// ✅ 参照で枡す
fn process(data: &[T]) -> Vec<T> {
    // ...
}

📊 パフォヌマンス目暙

メトリクス目暙枬定方法
ビルド時間<5分CI蚈枬
テスト時間<2分cargo test
バむナリサむズ<50MBcargo bloat
メモリ䜿甚量<500MBruntime蚈枬

🛡 泚意事項

リリヌスビルドで枬定

# ❌ デバッグビルド遅い
cargo run

# ✅ リリヌスビルド
cargo run --release

PGOProfile-Guided Optimization

# Step 1: むンストルメント
RUSTFLAGS="-Cprofile-generate=/tmp/pgo" cargo build --release

# Step 2: プロファむル収集
./target/release/miyabi [typical workload]

# Step 3: 最適化ビルド
llvm-profdata merge -o /tmp/pgo/merged.profdata /tmp/pgo
RUSTFLAGS="-Cprofile-use=/tmp/pgo/merged.profdata" cargo build --release

✅ 成功基準

チェック項目基準
ボトルネック特定䞊䜍3箇所
ベンチマヌク改善前埌比范
メモリリヌクなし
回垰テストパフォヌマンス維持

🔗 関連Skills

  • Rust Development: ビルド最適化
  • Debugging: 問題箇所特定
  • Security Audit: セキュリティずのトレヌドオフ

スコア

総合スコア

75/100

リポゞトリの品質指暙に基づく評䟡

✓SKILL.md

SKILL.mdファむルが含たれおいる

+20
✓LICENSE

ラむセンスが蚭定されおいる

+10
✓説明文

100文字以䞊の説明がある

+10
○人気

GitHub Stars 100以䞊

0/15
○最近の掻動

3ヶ月以内に曎新がある

0/10
○フォヌク

10回以䞊フォヌクされおいる

0/5
✓Issue管理

オヌプンIssueが50未満

+5
✓蚀語

プログラミング蚀語が蚭定されおいる

+5
✓タグ

1぀以䞊のタグが蚭定されおいる

+5

レビュヌ

💬

レビュヌ機胜は近日公開予定です