Performance Optimization 标志

Performance Optimization

社区
UnpaidAttention
performance-optimization

Make code measurably faster or leaner without breaking it — define a target, measure a baseline, profile to find the ACTUAL bottleneck, apply optimizations in a fixed order of leverage, and re-verify correctness after each change. Trigger this when the user reports slowness, high latency, memory growth, or cost, sets a performance budget, or asks to "optimize" or "speed up" something. Do NOT trigger for functional bugs that happen to involve timing (use debugging-methodology) or for restructuring at equal performance (use safe-refactoring) — this skill exists to move a number.

Add to TypingMind

概览

发布者UnpaidAttention
代码仓库fable5-methodology
技能名称performance-optimization
星标数
94
复刻数
21
附带文件
仅含指令
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 UnpaidAttention 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Performance Optimization AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/UnpaidAttention/fable5-methodology/tree/main/skills/performance-optimization
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/UnpaidAttention/fable5-methodology.git /tmp/fable5-methodology
mkdir -p .claude/skills
cp -r /tmp/fable5-methodology/skills/performance-optimization .claude/skills/performance-optimization
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Performance Optimization,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Performance Optimization。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Performance Optimization 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Performance Optimization

Optimization without measurement is guessing with extra steps. Intuition about bottlenecks is wrong often enough that acting on it unmeasured wastes the time it was meant to save. The number rules everything: define it, baseline it, move it, prove it.

Step 1: Define the target and the workload

  1. Pin the metric AND the goal: "p95 of /search under 300 ms at 50 rps", "import of the 1M-row file under 2 min", "RSS under 512 MB". No target = no definition of done = optimization that never ends. If the user gave none, propose one and get a nod.
  2. Pin the workload: realistic data at realistic scale. A query fast on 100 dev rows and slow on 10M production rows is the NORMAL case, not an edge case — measuring on toy data measures nothing.

Step 2: Baseline before any change

Measure the current number, three runs (warm), record median and spread in your notes. Every later claim of improvement is relative to this recorded baseline — "feels faster" is not a result.

Step 3: Profile — find where the time actually goes

Use the stack's profiler, not code reading:

  • Rust: cargo flamegraph / perf; --release always — debug-build numbers are fiction.
  • Node/TS: node --prof or 0x/clinic flame; console.time brackets for coarse cuts.
  • Python: py-spy record (no code change) or cProfile + snakeviz.
  • SQL: EXPLAIN (ANALYZE, BUFFERS) on the real query with real data volume.
  • Anything network-y: count the requests first — chattiness dominates before CPU does.

Read the profile for the top consumer. Rule: no optimization is applied to code the profile didn't indict. If the profile surprises you (it usually does), that surprise just saved you a week of optimizing the wrong thing.

Step 4: Apply strategies in order of leverage

Try each level; only descend when the level above is exhausted for the indicted hotspot:

  1. Don't do the work: cache repeated computation, dedupe repeated calls, early-exit, skip unused fields, paginate instead of load-all.
  2. Do the work fewer times / in bulk: fix N+1 queries (join or batch), batch writes, buffer I/O, debounce, move loop-invariant work out of the loop.
  3. Do the work better: right algorithm/data structure — dict lookup over list scan, sort-then-merge over nested loops, the missing database index.
  4. Tune the machinery: connection pools, buffer sizes, compiler/runtime flags, --release.
  5. Parallelize: only now — parallel versions of wasteful work multiply the waste and add race conditions to it.
  6. Micro-optimize: last, rarely, and only with the profile still pointing there.

Step 5: One change, two measurements

For EACH optimization: apply it alone → re-run the metric → re-run the correctness suite. Keep a running table in your notes:

Changep95 beforep95 afterTests
Add index on orders(user_id, created_at)1400 ms310 msgreen
Batch the price lookups310 ms180 msgreen

A change that doesn't move the number gets REVERTED, even if it "should" help — dead optimizations are complexity with no dividend. A change that breaks a test is a bug, not a trade-off, unless the user explicitly accepts the trade.

Step 6: Stop at the target

When the target from Step 1 is met: stop. Further optimization is scope creep with a performance costume. Report the table, the final number vs. target, and any identified-but- unneeded next levers ("materialized view would take it to ~80 ms if ever needed").

Worked example

"The dashboard takes 8 s to load; get it under 2 s."

  • Target: p95 page-data endpoint < 2 s on the staging dataset (4M rows). Baseline: 8.1 s.
  • Profile (EXPLAIN + request log): intuition said "slow rendering"; reality: 41 sequential queries (N+1 on widgets) + one seq-scan aggregate. Rendering was 90 ms — untouched.
  • Level 2: batch widget query → 41 calls → 2. 8.1 s → 2.9 s. Suite green.
  • Level 3: index for the aggregate's filter → seq scan → index scan. 2.9 s → 1.3 s. Green.
  • Target met — STOP. Cache layer (level 1) noted as unneeded next lever, not built.
  • Report: table of both changes with numbers, final 1.3 s vs 2 s target, suite green.

Done when

The target metric from Step 1 is met and demonstrated by recorded before/after measurements on the realistic workload; every applied change is in the table with its own measured delta; the full correctness suite is green after the final state; ineffective changes were reverted; and no code the profiler didn't indict was "optimized".

常见问题

Performance Optimization AI 技能有什么作用?

Make code measurably faster or leaner without breaking it — define a target, measure a baseline, profile to find the ACTUAL bottleneck, apply optimizations in a fixed order of leverage, and re-verify correctness after each change. Trigger this when the user reports slowness, high latency, memory growth, or cost, sets a performance budget, or asks to "optimize" or "speed up" something. Do NOT trigger for functional bugs that happen to involve timing (use debugging-methodology) or for restructuring at equal performance (use safe-refactoring) — this skill exists to move a number.

为什么在 TypingMind 中使用 Performance Optimization?

因为您只需安装一次,就能搭配任何模型使用。Performance Optimization 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Performance Optimization?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/UnpaidAttention/fable5-methodology/tree/main/skills/performance-optimization。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Performance Optimization?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Performance Optimization 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Performance Optimization 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Performance Optimization AI 技能免费吗?

UnpaidAttention 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇