golang-performance
使用性能分析优化 Go 性能
Go 服务经常会因内存分配、GC 压力、I/O 等待或低效的热点路径而变慢。此技能将性能分析信号映射到有针对性的 Go 性能修复,并通过基准测试验证。
使用我的智能体安装
将此请求复制给你的智能体,其中包含权威 Skill 页面和清单。
Review the Skillstore skill "golang-performance" from https://skillstore.io/skills/samber-golang-performance.md and its manifest at https://skillstore.io/api/skills/samber-golang-performance/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智能体仍应展示其计划,并按安全策略请求必要确认。
Agent 可读资源
当 AI Agent、爬虫或脚本需要干净上下文,而不是读取完整页面时,请使用这些链接。
测试它
正在使用“golang-performance”。 一个 handler 延迟很高但 CPU 使用率很低。
预期结果:
回答应先检查 off-CPU 等待、阻塞的 goroutines、tracing spans 和上游调用,然后再对代码做微优化。
正在使用“golang-performance”。 堆性能分析显示有许多短生命周期的 buffer 分配。
预期结果:
回答应比较 slice 复用、有界 pooling 和安全复制规则,然后要求进行基准测试验证。
正在使用“golang-performance”。 基准测试显示某个循环占用了主要 CPU 时间。
预期结果:
回答应先检查算法复杂度、内联、缓存局部性和直接索引,再建议更底层的改动。
安全审计
安全All static findings were adjudicated as false positives. The matches occur in Markdown documentation, JSON evaluation prompts, example Go snippets, local profiling commands, or project metadata, with no evidence of malicious execution, exfiltration, prompt injection, or unauthorized file access.
风险因素
⚙️ 外部命令 (80)
🌐 网络访问 (4)
分享与引用此报告
分享版本化评估报告、中性徽章、嵌入卡片和引用。Skillstore 只报告证据,不判断该 Skill 是否安全。
复制报告链接
https://skillstore.io/skills/samber-golang-performance/audits/3?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/samber-golang-performance?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/samber-golang-performance?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/samber-golang-performance/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/samber-golang-performance.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>学术引用 (APA · BibTeX · CFF)
APA 引用
samber. (2026). golang-performance security audit report (audit version 3) [Author version 1.2.2]. Skillstore. https://skillstore.io/skills/samber-golang-performance/audits/3BibTeX 引用
@techreport{samber-samber-golang-performance-2026,
author = {samber},
title = {golang-performance security audit report (audit version 3)},
institution = {Skillstore},
year = {2026},
number = {3},
url = {https://skillstore.io/skills/samber-golang-performance/audits/3},
note = {Author version 1.2.2}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "golang-performance security audit report (audit version 3)"
version: "1.2.2"
type: report
authors:
- name: "samber"
date-released: "2026-07-06"
url: "https://skillstore.io/skills/samber-golang-performance/audits/3"
identifiers:
- type: other
value: "skillstore:samber-golang-performance:audit:3"
description: "Skillstore immutable audit report identifier"
比较变体
2 个可安装变体每位作者的技能都保持为独立的可安装项。推荐变体按 Skillstore 证据排序。
为什么此变体排名第一
89jobrien-golang-performance
2026-10-18
Skillstore 评分
评分依据 证据置信度: 高你能构建什么
审查缓慢的 API Handler
识别延迟是来自 Go 代码、数据库调用、网络等待、内存分配还是 JSON 开销。
降低内存分配压力
使用堆性能分析和基准测试来选择 slice、map、pooling 或复制策略。
防止性能回归
为优化后的热点路径添加基准测试对比、Prometheus 检查和文档。
试试这些提示
我的 Go 服务很慢,但我不知道瓶颈在哪里。请帮我在修改代码前选择性能分析步骤。
我有一个堆性能分析,显示某个 Go 函数中有大量内存分配。请解释可能原因,并一次提出一个经过基准测试的改动。
这个 Go 函数在 pprof 中占用了主要 CPU 时间。请从内联、缓存局部性、内存分配和算法改进角度审查它。
帮我创建基准测试、benchstat 和可观测性检查,以便在发布前捕获 Go 性能回归。
最佳实践
- 先做性能分析,选择一个假设,只改一处,并用 benchstat 进行比较。
- 在 runtime 调优或 unsafe 代码之前,优先减少内存分配并修复算法问题。
- 用基准测试数字和采用该模式的原因来记录优化后的热点路径。
避免
- 没有 pprof、tracing 或基准测试证据,仅凭直觉优化代码。
- 一次应用多项性能改动,而不隔离每项改动的效果。
- 在证明热点路径有可测量收益之前,就使用 unsafe、pooling 或 SIMD。