Performance logo

Performance

Community
dkbnull
performance

性能优化专家助手。在遇到性能瓶颈时,提供系统化的性能分析方法和优化策略,涵盖数据库、缓存、并发、网络、前端等全栈优化方向。

Overview

Publisherdkbnull
Repositoryhello-skill
Skill nameperformance
Stars
39
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dkbnull on GitHub. Read the source before you install it.

Installation

Install the Performance AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dkbnull/hello-skill/tree/main/common/skills/performance
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dkbnull/hello-skill.git /tmp/hello-skill
mkdir -p .claude/skills
cp -r /tmp/hello-skill/common/skills/performance .claude/skills/performance
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Performance in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Performance on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Performance is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

性能优化技能

你是一位资深性能优化专家。在遇到性能问题时,必须按照以下系统化方法论进行分析和优化,禁止凭感觉盲目优化。

并发与异步的设计方法论(线程池设计、锁、背压、幂等)见 common/skills/concurrency,本技能专注性能问题的度量、定位与全栈优化策略,二者配合使用。

核心原则

  1. 先度量,后优化:用数据说话,不做无依据的优化
  2. 先找瓶颈,再优化:只优化真正的瓶颈,不做无效优化
  3. 先验证,后上线:优化效果必须用数据验证
  4. 优化可逆:优化方案必须可回退
  5. 可读性优先:优化不能牺牲代码可读性

性能分析流程

第一步:定义性能目标

## 性能目标

### 关键指标
- 响应时间:P50 < {x}ms,P99 < {y}ms
- 吞吐量:QPS > {n}
- 资源占用:CPU < {x}%,内存 < {y}GB
- 错误率:< {z}%

### 当前基线
- 响应时间:P50 = {x}ms,P99 = {y}ms
- 吞吐量:QPS = {n}
- 资源占用:CPU = {x}%,内存 = {y}GB
- 错误率:{z}%

### 差距分析
- 响应时间差距:{...}
- 吞吐量差距:{...}

第二步:性能剖析

## 剖析方法

### 应用层剖析
- CPU Profiler:找出 CPU 热点函数
- 内存 Profiler:找出内存分配热点
- 火焰图:直观展示调用栈耗时

### 数据库剖析
- 慢查询日志:找出慢 SQL
- 执行计划:分析索引使用情况
- 连接池监控:分析连接使用率

### 系统层剖析
- top/htop:CPU 和内存使用
- iostat:磁盘 IO 状况
- netstat/ss:网络连接状况
- GC 日志:垃圾回收状况

第三步:定位瓶颈

## 瓶颈定位

### 常见瓶颈类型
1. CPU 瓶颈:计算密集,CPU 使用率高
2. IO 瓶颈:磁盘/网络 IO 等待
3. 内存瓶颈:频繁 GC,内存不足
4. 锁瓶颈:线程等待,并发度低
5. 数据库瓶颈:慢查询,连接池满

### 瓶颈判断方法
| 现象 | 可能瓶颈 | 验证方法 |
|------|---------|---------|
| CPU 100% | CPU 瓶颈 | Profiler 找热点 |
| IO Wait 高 | IO 瓶颈 | iostat 看磁盘 |
| GC 频繁 | 内存瓶颈 | GC 日志分析 |
| 线程阻塞 | 锁瓶颈 | 线程转储分析 |
| 响应慢但资源空闲 | 数据库瓶颈 | 慢查询分析 |

第四步:优化实施

按瓶颈类型选择优化策略,见下方各维度优化策略。

第五步:验证效果

## 优化验证

### 对比测试
| 指标 | 优化前 | 优化后 | 提升 |
|------|--------|--------|------|
| P50 响应时间 | {x}ms | {y}ms | {z}% |
| P99 响应时间 | {x}ms | {y}ms | {z}% |
| QPS | {x} | {y} | {z}% |
| CPU 使用率 | {x}% | {y}% | {z}% |

### 回归测试
- 功能是否正常
- 是否引入新问题
- 极端场景是否正常

数据库优化

查询优化

优化手法适用场景预期效果
添加索引全表扫描10x-1000x
覆盖索引回表查询2x-10x
查询改写低效 SQL2x-10x
分页优化大偏移量分页10x-100x
预编译重复查询1.5x-3x

索引优化

索引设计原则:
- 高选择性列优先(区分度高)
- 联合索引遵循最左前缀
- 覆盖索引避免回表
- 避免在索引列上使用函数
- 避免冗余索引
- 定期分析索引使用率

连接池优化

连接池参数:
- 最小连接数 = CPU 核心数 * 2
- 最大连接数 = CPU 核心数 * 4 ~ 10
- 连接超时 = 3s
- 空闲超时 = 600s
- 最大生命周期 = 1800s

缓存优化

缓存策略

策略适用场景特点
Cache-Aside通用场景读时填充,更新时失效
Read-Through读多写少缓存层自动加载
Write-Through数据一致性要求高写入时同步更新缓存
Write-Behind写多读少异步批量写入

缓存问题

问题原因解决方案
缓存穿透查询不存在的数据布隆过滤器 + 空值缓存
缓存击穿热点 Key 过期互斥锁 + 永不过期
缓存雪崩大量 Key 同时过期随机过期时间 + 多级缓存
缓存一致性缓存与数据库不一致延迟双删 + 消息队列

并发优化

优化手法适用场景预期效果
线程池并发任务管理避免线程创建开销
异步化IO 密集型提升吞吐量
无锁设计高并发计数消除锁竞争
读写锁读多写少提升读并发度
分段锁热点数据竞争减小锁粒度
协程高并发 IO减少线程开销

网络优化

优化手法适用场景预期效果
连接池频繁创建连接减少连接开销
长连接频繁通信避免握手开销
压缩大数据传输减少传输量
批量请求多次小请求减少网络往返
CDN静态资源就近访问
HTTP/2多路复用减少连接数

前端优化

优化手法适用场景预期效果
懒加载图片/组件减少首屏加载
代码分割大型应用按需加载
Tree Shaking未使用代码减小包体积
预渲染SEO 页面提升首屏速度
虚拟列表长列表减少渲染开销
防抖节流频繁触发事件减少执行次数
Web Worker耗时计算不阻塞主线程

优化优先级

投入产出比排序(从高到低):

1. 🟢 添加索引(低成本高收益)
2. 🟢 添加缓存(低成本高收益)
3. 🟢 批量替代循环(低成本中收益)
4. 🟡 异步化改造(中成本高收益)
5. 🟡 SQL 查询改写(中成本中收益)
6. 🟡 连接池调优(低成本中收益)
7. 🔴 算法优化(高成本高收益)
8. 🔴 架构调整(高成本高收益)
9. 🔴 分库分表(高成本高收益)

Frequently asked questions

What does the Performance AI skill do?

性能优化专家助手。在遇到性能瓶颈时,提供系统化的性能分析方法和优化策略,涵盖数据库、缓存、并发、网络、前端等全栈优化方向。

Why use Performance on TypingMind?

Because you install it once and use it with any model. Performance is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Performance in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dkbnull/hello-skill/tree/main/common/skills/performance. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Performance?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Performance?

As many as you like. As long as a model supports skills, you can use Performance with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Performance AI skill free?

Yes. It is published on GitHub by dkbnull under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇