一键导入
perf
Investigate performance bottlenecks with Seastar-aware analysis. Use when the user asks about performance, latency, throughput, optimization, or profiling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Investigate performance bottlenecks with Seastar-aware analysis. Use when the user asks about performance, latency, throughput, optimization, or profiling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Hostile security and robustness audit of src/ assuming malicious traffic and 100x load. Use before releases, after large feature merges, or when the user asks for a security audit, adversarial review, or "what breaks under attack".
Holistic system audit for architecture drift, Hard Rules compliance, and async integrity across recently changed code. Use after completing a batch of tasks, before a release, or when the user asks for a health check or audit.
Semantic-correctness audit of hot-path code - enumerate the invariants a component must maintain, then hunt code paths that violate them (wrong answers, not crashes). Use after changing routing, eviction, accounting, or counter logic, before a release, or when metrics drift without any crash.
Orientation for a session starting work on this codebase - reading order, where things live, which skill to use for which task, and the non-negotiable constraints. Use at the start of a session, when unsure where to look, or when the user asks how to approach a task here.
Plan, run, and interpret Locust load benchmarks (mock-backend and real-GPU) including A/B routing experiments. Use when the user wants to measure cache-hit ratio, TTFT, or throughput, compare routing modes, chase a benchmark regression, or design a benchmark experiment.
Triage build or runtime failures. Use when the user pastes a compile error, link error, runtime crash, test failure, or error log, or mentions a build failure.
| name | perf |
| description | Investigate performance bottlenecks with Seastar-aware analysis. Use when the user asks about performance, latency, throughput, optimization, or profiling. |
| argument-hint | ["component-or-feature"] |
| allowed-tools | Read, Grep, Glob |
Area: $ARGUMENTS
Ref:
.dev-context/claude-context.mdfor build constraints, architecture, coding conventions, and the Hard Rules.
| Type | Symptoms | Investigation |
|---|---|---|
| CPU-bound | High CPU, low I/O wait | Profile hot functions |
| I/O-bound | Low CPU, high I/O wait | Check network/disk patterns |
| Memory-bound | Cache misses, allocation overhead | Check data structures |
| Contention-bound | Variable latency, cross-shard calls | Check shard distribution |
Metric: [what we're measuring]
Current Value: [number]
Measurement Method: [how we measured]
| Technique | When to Use | Trade-off | Gains |
|---|---|---|---|
parallel_for_each | Sequential co_await in loops | Memory up | Latency down |
max_concurrent_for_each | Need bounded parallelism | Complexity up | Controlled concurrency |
| Batching | Many small I/O operations | Latency up | Throughput up |
| Shard-local caching | Repeated cross-shard reads | Memory up | Latency down |
| Object pooling | Frequent alloc/dealloc | Memory up | Allocation down |
| Current | Optimized | When Applicable |
|---|---|---|
| O(n) search | O(1) hash lookup | Known key space |
| O(n^2) nested loop | O(n log n) sort + scan | Sortable data |
| String copying | String views | Read-only access |
| Dynamic allocation | Stack allocation | Small, fixed size |
| Anti-Pattern | Why It Fails | Rule # |
|---|---|---|
Add std::mutex for "thread safety" | Blocks reactor | #1 |
| Over-parallelize (unbounded futures) | Memory exhaustion | #4 |
Cache with std::shared_ptr | Cross-shard ref counting | #0 |
| Synchronous file I/O | Blocks reactor | #12 |
Type: [CPU/I/O/Memory/Contention]
Location: [file:function:line]
Current Complexity: O([complexity])
Root Cause: [why it's slow]
// Before (showing why it's slow)
[code]
// After (with explanation)
[code]
| Metric | Before | After (Expected) | Confidence |
|---|---|---|---|
| Throughput | X req/s | Y req/s | [High/Medium/Low] |
| Latency p99 | X ms | Y ms | [High/Medium/Low] |
docs/internals/request-lifecycle-perf-analysis.md documents the existing hot-path mitigations (route batching, tokenization fallback, stale-connection retries, load-aware overrides) — don't re-derive or accidentally undo them./benchmark. This sandbox cannot execute benchmarks; emit the exact commands for the developer.make bench-hot-prefix, make bench-epp (see /validate for the full toolchain).