harness-perf-playbook

Harness performance optimization playbook: Practical optimizations from the StepFun Harness P4 federated sync module, documenting 5 hidden pitfalls, 7 remediation patterns, and one checklist. Includes a case with 4–500x performance improvement and covers common performance traps such as list-API optimization, filename hard-coding, and urllib.timeout imprecision.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "harness-perf-playbook" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-6083d5d0b54ce1f804f8add052cd90dda1b3beb547c1bf3d12fde715591badf2. Verify the upstream source and version against https://skillhub.cn/skills/user_d353d7f3/harness-perf-playbook before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Harness performance optimization playbook: Practical optimizations from the StepFun Harness P4 federated sync module, documenting 5 hidden pitfalls, 7 remediation patterns, and one checklist. Includes a case with 4–500x performance improvement and covers common performance traps such as list-API optimization, filename hard-coding, and urllib.timeout imprecision.

0 Downloads

Introduction source: third_party · user_d353d7f3 · 1.0.0 Reference

SkillPi interpretation

Tasks
|
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: "harness-perf-playbook"
description: "|"

--- name: harness-perf-playbook version: 1.0.0 author: wanglin1111111 description: | Harness 性能优化实战手册,包含 5 个隐藏坑、7 个修复模式和 1 套 Checklist。来源:StepFun Harness P4 联邦同步模块的实战优化,性能提升 4-500x。涵盖列表 API 优化、文件名硬编码问题、urllib.timeout 不精确等常见性能陷阱。

Harness 性能优化实战手册

5 个隐藏坑 + 7 个修复模式 + 1 套 Checklist 来源:StepFun Harness P4 联邦同步模块的实战优化 时间:2026-06-07 性能提升:4-500x

实战数据

场景 优化前 优化后 提升
完整 e2e (17 tests) 冷启 60-117s 15.5s 4-7x
完整 e2e (17 tests) 热缓存 ~60s 8.3s 7-12x
Federation sync 冷启 12-24s 1.5s 8-16x
Federation sync 缓存命中 12-24s 0.05-0.18s 100-500x
离线场景 12-24s (反复超时) 0.7s (探测后跳走) 17-34x

5 个隐藏坑

坑 #1:列表 API 返回数量不可控(最致命)

# 期望
skill_names = list_github_dir(repo, "skills")  # 假设 5-10 个

# 现实
skill_names = list_github_dir(repo, "skills")  # 88 个子目录
for sn in skill_names:
    fetch(sn)  # × 88 次 HTTPS = 12-24s

避免:

MAX_SKILLS_PER_SOURCE = 20
if len(skill_names) > MAX_SKILLS_PER_SOURCE:
    print(f"[WARN] capping {len(skill_names)} → {MAX_SKILLS_PER_SOURCE}")
    skill_names = skill_names[:MAX_SKILLS_PER_SOURCE]

坑 #2:文件名硬编码(87/88 次 404 浪费)

# 代码假设
text = fetch(f"{subpath}/{name}/skill.yaml")  # 全 404

# 实际仓库可能是
skills/xxx/SKILL.md           # 大写 .md
skills/xxx/manifest.json      # 不同命名
skills/xxx/package.json       # npm 风格

避免:

# 1. 添加源前先探测目录结构
curl -s https://api.github.com/repos/{owner}/{repo}/contents/{path}/{sample} | jq '.[].name'

# 2. 工具支持 --filename 参数(不要硬编码)
harness federate add --filename SKILL.md

坑 #3:urllib.timeout 不精确

# 误以为
urllib.request.urlopen(url, timeout=3)  # 一定 3s 内返回

# 实际行为(DNS 失败/连接被 RST/TLS 卡住)
TCP 连接建立: 受 OS SYN_RETRANSMISSION 影响, 可能 30s+
DNS 解析:     不受 timeout 控制, 依赖系统 resolver
TLS 握手:     额外 1-30s
只有数据传输: 严格受 timeout=3 控制

实测延迟: | 场景 | timeout=3 实际耗时 | |------|-------------------| | 正常可达 | 0.35-0.50s ✅ | | DNS 解析失败 | 5-30s ❌ | | 连接被 RST | 3-10s ❌ | | TLS 握手卡住 | 10-30s ❌ |

避免:

# 方案A: socket 全局默认超时
import socket
socket.setdefaulttimeout(3)

# 方案B: 双重超时(soft + hard)
def fetch(url, soft=3, hard=10):
    ...

7 个修复模式

  1. 列表截断:限制每次获取的技能数量
  2. 动态探测:先探测目录结构再决定文件名
  3. 双重超时:socket 全局超时 + 单次请求超时
  4. 连接复用:使用 requests.Session 或 urllib3 PoolManager
  5. 缓存策略:TTL 缓存 + stale-while-revalidate
  6. 渐进式加载:先加载元数据,再按需加载详情
  7. 离线降级:探测失败时快速跳走,不阻塞

Checklist

  • [ ] 限制列表 API 返回数量(MAX_SKILLS_PER_SOURCE)
  • [ ] 探测目录结构而非硬编码文件名
  • [ ] 设置 socket 全局超时
  • [ ] 使用连接池复用 HTTP 连接
  • [ ] 实现缓存层减少重复请求
  • [ ] 添加离线降级逻辑
  • [ ] 监控关键路径耗时

许可证

MIT License

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 Harness 性能优化的实战手册,包含具体优化案例和实测数据
  • 涵盖 5 个隐藏坑、7 个修复模式和完整 Checklist,实用价值高
  • 性能提升数据详实(4-500x),解决开发者实际痛点
Trigger Precision70/100

Areas to improve

  • description 写错位置 Reported severity: Minor

    顶层 description 字段为空,但 skill_body 内部有完整描述

    Recommendation: 将 description 内容移至顶层 frontmatter 的 description 字段

Highlights

  • 内容本身包含清晰的 Harness 性能优化触发场景描述
Structure and Standards70/100

Areas to improve

  • 缺少 When to Use 章节 Reported severity: Minor

    文档缺少明确的使用场景说明章节

    Recommendation: 添加 When to Use 章节说明适用场景和使用方法

  • frontmatter 重复定义 Reported severity: Minor

    name 和 description 字段在 frontmatter 中重复定义

    Recommendation: 清理重复的 frontmatter 定义,保留一份即可

Highlights

  • 结构完整,包含实战数据、隐藏坑、修复模式等清晰章节
  • 提供具体代码示例和实测数据支撑
Execution Reliability85/100

Highlights

  • 提供具体可行的优化方案和代码示例
  • 包含多种场景的实测性能指标,数据详实可靠
  • 修复模式具体明确,Checklist 完整实用
Evidence Verifiability (mean of the first four)78/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • api.github.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

caution · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.