go-inline-budget-optimization
Systematically reduce Go function cost below the 80-unit inlining budget for hot-path performance
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Systematically reduce Go function cost below the 80-unit inlining budget for hot-path performance
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Add performance benchmarks to hot-path functions that run on every state update (settings, auth, etc.) to establish baselines and catch regressions
When updating AGENTS.md or after any dependency changes, cross-reference package.json versions against AGENTS.md to ensure accuracy
Orchestrator-only workflow for heavy coding sessions, multi-phase implementation, and risky refactors. Use for complex work that needs planning, review gates, and persistent progress tracking.
Configure and improve oh-my-opencode-slim for the current user. Use when users want to tune agents, models, prompts, custom agents, skills, MCPs, presets, or plugin behavior. Also use when recurring workflow friction suggests a safe config or prompt improvement.
استنادا إلى تصنيف SOC المهني
| name | go-inline-budget-optimization |
| description | Systematically reduce Go function cost below the 80-unit inlining budget for hot-path performance |
Go 1.26 has an inlining budget of 80 cost units. Functions exceeding this are not inlined, which matters for hot-path performance in HTTP routers.
go build -gcflags='-m=2' ./package to get exact cost per functioncannot inline <func>: function too complex: cost N exceeds budget 80inlining call to <func> vs those that don'tvar ss string; ss = s[a:b] creates a new string header every iteration, forcing heap escapingss != "" after already knowing the range is non-empty adds branchessep uint8 when all callers pass '/' — consider inlining the constantif != sep { if < len-1 { continue } i = len } with a single loop that checks conditions inline-gcflags='-m=2' that cost dropped below 80Before (cost 86):
func splitPathFn(s string, sep uint8, fn func(p string, pidx, idx int) bool) bool {
var pi, last int
var ss string
for i := 0; i < len(s); i++ {
if s[i] != sep {
if i < len(s)-1 {
continue
}
i = len(s)
}
if ss = s[last:i]; ss != "" {
if fn(ss, pi, i) { return true }
last = i
pi++
}
}
return false
}
After (cost 80):
func splitPathFn(s string, sep uint8, fn func(p string, pidx, idx int) bool) bool {
pi, last := 0, 0
for i := 0; i < len(s); i++ {
if s[i] != sep {
if i < len(s)-1 {
continue
}
i = len(s)
}
if last < i {
if fn(s[last:i], pi, i) {
return true
}
last = i
pi++
}
}
return false
}
Key changes: eliminated ss variable, flattened control flow, removed redundant empty check.
go test ./... to verify correctness-gcflags='-m=2' output for can inline <func> with cost N where N < 80inlining call to <func>