Skip to content

perf: optimize YAML generation hot paths (-7% latency, -10% allocations)#29409

Merged
pelikhan merged 2 commits intomainfrom
copilot/performance-regression-yamlgeneration
May 1, 2026
Merged

perf: optimize YAML generation hot paths (-7% latency, -10% allocations)#29409
pelikhan merged 2 commits intomainfrom
copilot/performance-regression-yamlgeneration

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

BenchmarkYAMLGeneration reported a +18.8% regression (1.76ms vs 1.48ms baseline). Profiling revealed several allocation-heavy hot paths in the compilation pipeline that could be tightened.

Changes

  • pkg/actionpins — Replace fmt.Sprintf with string concatenation in FormatCacheKey and FormatPinnedActionReference; these are called 655K+ times per benchmark run

  • pkg/workflow/expression_nodes — Replace fmt.Sprintf with string concatenation in the four hot Render() methods (StringLiteralNode, ComparisonNode, FunctionCallNode, NotNode); ~1.5M allocs/run eliminated. Drops the unused fmt import.

  • pkg/workflow/agentic_engine — Pre-compute GetAllAgentManifestFiles/GetAllAgentManifestFolders at NewEngineRegistry() construction time. Subsequent calls return the cached slice with zero allocations. Falls back to on-demand computation for registries created directly (tests).

  • pkg/workflow/jobs — Pre-size strings.Builder in RenderToYAML (96 KB) and renderJob (8 KB) to reduce reallocation churn during YAML rendering.

  • pkg/workflow/action_cache — Add GetByCacheKey(key string) to allow callers to reuse a pre-computed key.

  • pkg/workflow/action_resolver — Use GetByCacheKey in ResolveSHA so the cache key string is allocated once instead of twice per call.

Result

Metric Before After Δ
ns/op ~1,366 ~1,266 -7.3%
B/op 1,029 KB 966 KB -6.1%
allocs/op 4,937 4,428 -10.3%

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json GO111MODULE tartedAt,updatedAt,event,headBranch,headSha,displayTitle GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw GOMOD GOMODCACHE go env 1730-34817/test-source-field-variant-630703077/.github/workflows GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name -c=4 -nolocalimports -importcfg /tmp/go-build3105686641/b434/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/repoutil/repoutil.go /home/REDACTED/work/gh-aw/gh-aw/pkg/repoutil/repoutil_test.go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name gine.go git repository(owne168.63.129.16 --show-toplevel git /usr/bin/git git rev-�� ithub/workflows git kflows/daily-cac-lang=go1.25 --show-toplevel git /usr/bin/git cp (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq [.object.sha, .object.type] | @tsv GOMODCACHE 64/pkg/tool/linux_amd64/compile /usr/bin/git 144764234 GO111MODULE ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel go /usr/bin/git 7942/001/stabilinode GO111MODULE ache/go/1.25.8/xinstall git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq [.object.sha, .object.type] | @tsv xterm-color ache/go/1.25.8/x64/pkg/tool/linuconfig /usr/bin/git y_with_repos=pubgit show p/bin/git git rev-�� --show-toplevel git /usr/bin/git b37d304bed92cd99node config ache/CodeQL/2.25install git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv y --jq /usr/bin/infocmp -json GO111MODULE 64/bin/go infocmp -1 xterm-color go /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv /home/REDACTED/work/gh-aw/gh-aw/.github/workflows rev-parse /usr/bin/git --noprofile git me: String!) { --show-toplevel git remo�� add origin /usr/bin/git kflow/action_resgit -f (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv g/constants/constants.go g/constants/engine_constants.go ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile env 1730-34817/test-3693125017/.github/workflows GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE b/gh-aw/pkg/envurev-parse GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel go /usr/bin/git 1730-34817/test-git GO111MODULE 1/x64/bin/node git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /usr/bin/git vaScript26989425git GO111MODULE 1/x64/bin/node git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv tags/v4 git sv /tmp/gh-aw-test-git rev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel go /usr/bin/git git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv w/js/**/*.json' --ignore-path /tmp/go-build267../../../.prettierignore cal/bin/bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -bool ache/go/1.25.8/x64/src/cmd/vendo--ignore-path 86_64/bash -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu-trimpath -o th .prettierignore --log-level=error -trimpath /snap/bin/bash -p cmd/vendor/golanrev-parse -lang=go1.25 bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv rd (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq [.object.sha, .object.type] | @tsv --show-toplevel 64/pkg/tool/linux_amd64/link /usr/bin/git ingutil.test GO111MODULE ortcfg.link git rev-�� --show-toplevel WSXRyBZ2GEm4H7IUTM/LO7H8yrdtF7RvFVPrIMI/Ghy3DT33Rik9SPHCtMYQ /usr/bin/git mplied GO111MODULE g_.a git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq [.object.sha, .object.type] | @tsv --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /usr/bin/git OO5h/j2hYVVfbxVYgit git ache/go/1.25.8/x64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /usr/bin/git 215061/b345/embegit git 0723324/b306/vet--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv -t security tions/setup/js/node_modules/.bin/node OUTPUT -d 168.63.129.16 bash tion�� --noprofile 53 de_modules/.bin/sh ACCEPT /counter.go x_amd64/vet ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv -t security de_modules/.bin/node OUTPUT -d 168.63.129.16 bash tion�� --noprofile owner h 0 -j ACCEPT ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv 939627/b369/_pkg_.a atted/golang/pkg/flatted/flatted.go de_modules/.bin/sh (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv on_test.go _test.go k/_temp/uv-python-dir/bash /tmp/mem.prof (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv GOMODCACHE go /usr/bin/gh -json GO111MODULE ache/go/1.25.8/x--show-toplevel gh run view 12345 /usr/bin/git nonexistent/repogit --json status,conclusio--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel infocmp /usr/bin/infocmp f9e1eb1b:pkg/worgit git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv -x c ode - (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv runs/20260501-001730-34817/test-1313364113 s/3/artifacts /usr/bin/git -json GO111MODULE 64/bin/go git rev-�� --show-toplevel go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -json GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/bash git rev-�� --show-toplevel go /usr/bin/git 47977248/001 GO111MODULE ache/go/1.25.8/x--show-toplevel git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv w/js/**/*.json' --ignore-path /tmp/go-build267../../../.prettierignore 1/x64/bin/bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv json' --ignore-path ../../../.pr**/*.json ache/go/1.25.8/x64/src/cmd/vendo--ignore-path sh -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu-pack -o th .prettierignore --log-level=error -trimpath ache/uv/0.11.8/x86_64/git -p cmd/vendor/golanrev-parse -lang=go1.25 bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv ../pkg/workflow/js/**/*.json' --ignore-path ../../../.prettierignore (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv : ${{ github.repository }} remote /usr/bin/git /tmp/go-build373git -trimpath 64/bin/go git -C /tmp/gh-aw-test-runs/20260501-001730-34817/test-254765070/custom/workflows rev-parse /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv xterm-color 4f56133af59281f19e2dcd69 /usr/bin/git _nodes.go --jq (http block)
  • https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv --show-toplevel nly /usr/bin/git --git-dir go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git --show-toplevel resolved$ /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/node/24.14.1/x64/bin/node /usr/bin/git github.actor hanges) /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .default_branch --show-toplevel git /usr/bin/git --show-toplevel ache/go/1.25.8/x-1 /usr/bin/git git rev-�� --show-toplevel git docker-compose --show-toplevel go /usr/bin/git docker-compose (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq [.object.sha, .object.type] | @tsv --git-dir go /usr/bin/gh -json GO111MODULE 64/bin/go gh secr�� list --json /usr/bin/git mpiledOutput2145git GO111MODULE ache/go/1.25.8/x--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/infocmp hub/workflows rev-parse /usr/bin/git infocmp -1 xterm-color git /usr/bin/git k/gh-aw/gh-aw/.ggit rev-parse 64/bin/bash git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv /tmp/TestGuardPolicyBlockedUsersCommaSeparatedCompiledOutput3718440129/001 rev-parse /usr/bin/git /tmp/go-build373git -trimpath 64/bin/go git -C /home/REDACTED/work/gh-aw/gh-aw/.github/workflows rev-parse .cfg -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv ons-test2414940696 git /usr/bin/git ithub/workflows git /usr/bin/git git remo�� ed } } git om/org2/repo.git k/gh-aw/gh-aw/.ggit git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv k/gh-aw/gh-aw/.github/workflows/api-consumption-diagnostic noise should not be returned 5686641/b450/_testmain.go /usr/bin/git /tmp/go-build373git -trimpath 64/bin/go git rev-�� --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv ons-test2414940696 -tests /usr/bin/git k/gh-aw/gh-aw git kflows/cloclo.lo--show-toplevel git rev-�� --show-toplevel git me: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } --show-toplevel :latest (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-24 GOMOD GOMODCACHE go env add-source-path-2099368145/.github/workflows GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-01 GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-01-31 GOMOD GOMODCACHE BW/Vpa8Q5oQtl-xBNfdPDXU/ABhVdekO--auto env ty-test.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linutest@example.com env 3693125017 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env rdian.md GO111MODULE k GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name config ache/go/1.25.8/x64/bin/git remote.origin.urgh /usr/bin/git DiscussionsEnabllist git -C o actions/setup---limit rev-parse cal/bin/git json; \ cp .gitgit git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu--json estl�� ntdrain.test GO111MODULE ortcfg.link GOINSECURE GOMOD GOMODCACHE qyt2rkmdiK-YsnbcBW/Vpa8Q5oQtl-xBNfdPDXU/ABhVdekO--auto (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name mLsRemoteWithRealGitcustom_branch3249265077/001' ache/go/1.25.8/x64/pkg/tool/linux_amd64/asm --show-toplevel gh /usr/bin/git ache/go/1.25.8/xremote1 -1 1/test1.md git t --show-toplevel git r: $owner, name:--show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 144764234 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name config ache/go/1.25.8/x64/pkg/tool/linux_amd64/cgo l infocmp /usr/bin/git ache/go/1.25.8/x64/pkg/tool/linuremote.origin.url -C y_with_explicit_repo2911649378/001 rev-parse rgo/bin/git --show-toplevel git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 08/001/test-empty-frontmatter.md GO111MODULE k GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name show ache/node/24.14.1/x64/bin/git l /usr/bin/git $name) { hasxterm-color git -C ut789382956/001 config 64/pkg/tool/linux_amd64/vet remote.origin.urgit /usr/bin/gh DiscussionsEnabled } } 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env stants.test GO111MODULE ortcfg.link GOINSECURE GOMOD GOMODCACHE nt9zLENvjKcOLdPac7/zhJWMtxx0i81O-buildtags (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 08/001/test-frontmatter-with-env-s GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name -f kflows/terminal-stylist.lock.yml -f owner=github -f git -C ut789382956/001 show rgo/bin/git --show-toplevel infocmp /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env g_.a GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 08/001/test-complex-frontmatter-with-tools.md GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name mLsRemoteWithRealGitbranch_with_hyphen2754835429/001' cal/bin/git install --package-lock-oconfig $name) { has--get-regexp /usr/bin/gh api ut789382956/001 -f nfig/composer/vendor/bin/git -f owner=github -f git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name GO111MODULE x_amd64/link GOINSECURE GOMOD GOMODCACHE x_amd64/link env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env g_.a GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name rev-parse t install --package-lock-orun /usr/bin/git infocmp -1 xterm-color git p/bin/git --show-toplevel gh /usr/bin/git /usr/bin/gh (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path "prettier" --cheGOINSECURE node 64/bin/go --write ../../../**/*.js-atomic 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOMOD GOMODCACHE NfdPDXU/ABhVdekO--auto env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 3555721929 .cfg ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/contents/.github/workflows/shared/reporting.md
    • Triggering command: /tmp/go-build3105686641/b404/cli.test /tmp/go-build3105686641/b404/cli.test -test.testlogfile=/tmp/go-build3105686641/b404/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE 1047116/b403/impGO111MODULE -c k/gh-aw/gh-aw/pkGOINSECURE GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcGO111MODULE (http block)
    • Triggering command: /tmp/go-build2740723324/b404/cli.test /tmp/go-build2740723324/b404/cli.test -test.testlogfile=/tmp/go-build2740723324/b404/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true --show-toplevel git /usr/bin/git ker/cli-plugins/docker-compose n-me�� ns.go git me: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } --show-toplevel git-upload-pack /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq [.object.sha, .object.type] | @tsv tags/v6 ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet sv -json GO111MODULE /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq [.object.sha, .object.type] | @tsv tags/v6 git sv /home/REDACTED/worgit config ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv 08/001/test-frontmatter-with-arrays.md GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE .cfg GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv 1123943765 ghcr.io/github/serena-mcp-server:latest /usr/bin/gh --show-toplevel git $name) { has--show-toplevel /usr/bin/gh api sRemoteWithRealGitmain_branch181remote.origin.url sRemoteWithRealGitmain_branch18105460/002/work .cfg -f owner=github -f ache/go/1.25.8/x64/pkg/tool/linux_amd64/asm (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go _bra�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv /setup/js/sanitize_content.test.cjs git ature-coverage.lock.yml --show-toplevel ache/node/24.14./tmp/js-hash-test-938726339/test-hash.js /usr/bin/git infocmp 0546�� kflow/jobs.go git x_amd64/vet --show-toplevel ache/node/24.14.-C /usr/bin/git x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv with-tools.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env Gitmaster_branch1846335021/001' Gitmaster_branch1846335021/001' 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go 6362�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq [.object.sha, .object.type] | @tsv -c=4 -nolocalimports -importcfg /tmp/go-build3105686641/b443/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/stats/statvar.go /home/REDACTED/work/gh-aw/gh-aw/pkg/stats/spec_test.go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq [.object.sha, .object.type] | @tsv /setup/js/saniti-errorsas remote.origin.ur-ifaceassert compliance.lock.-nilfunc --show-toplevel git ed } } efVGZn9/8JVJIp-q-tests -C kflow/jobs.go show rcer.lock.yml --show-toplevel node /usr/bin/git /usr/bin/gh (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq [.object.sha, .object.type] | @tsv se 3236518/b227/vet.cfg modules/@npmcli/run-script/lib/node-gyp-bin/sh (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq [.object.sha, .object.type] | @tsv md GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env DefaultBranchFromLsRemoteWithRealGitbranch_with_hyphen3146897395/001' DefaultBranchFromLsRemoteWithRealGitbranch_with_hyphen3146897395/001' /opt/hostedtoolcache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq [.object.sha, .object.type] | @tsv b37d304bed92cd99f9e1eb1b:actions/setup/js/comput-c=4 git k --show-toplevel git r: $owner, name:--show-toplevel git sRem�� b37d304bed92cd99f9e1eb1b:pkg/workflow/expression_nodes.go rev-parse /usr/bin/git ache/go/1.25.8/xgit git r: $owner, name:--show-toplevel git (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go env /ref/tags/v9 GO111MODULE sv GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion --show-toplevel /usr/bin/git $name) { has--show-toplevel git -C b37d304bed92cd99f9e1eb1b:actions--workflow config rgo/bin/git remote.origin.urgit /opt/hostedtoolcrev-parse /usr/bin/tr git (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go tierignore ../../../**/*.js-atomic 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --repo owner/repo --json name,path,state ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 7942/001/stability-test.md GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo me: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } f/tags/v4 VWw7VJguVlRAx/jN-V=full sv git rev-�� ithub/workflows git ml --show-toplevel git /usr/bin/git git (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name "prettier" --cheGOINSECURE node 64/bin/go --write ../../../**/*.js-V=full 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name gine.go git t-burner.lock.ym168.63.129.16 l ache/go/1.25.8/x-V=full /usr/bin/git git rev-�� ithub/workflows git ock.yml --show-toplevel git DiscussionsEnabl/repos/actions/github-script/git/ref/tags/v9 make (http block)
  • https://api.github.com/repos/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch 254765070/custom/workflows GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch alse config /usr/bin/infocmp elete infocmp b37d304bed92cd99--show-toplevel infocmp -1 b37d304bed92cd99f9e1eb1b:pkg/workflow/action_resolver.go x_amd64/compile p/bin/bash run --auto $name) { has--get-regexp git (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…ssion

Profile-guided optimizations reducing BenchmarkYAMLGeneration from ~1.37ms to
~1.27ms (-7.3%), with 10% fewer allocations (4937→4428 allocs/op) and 6% less
memory per op.

Changes:
- pkg/actionpins: replace fmt.Sprintf with string concat in FormatCacheKey
  and FormatPinnedActionReference (hot paths, 655K+ allocs/run)
- pkg/workflow/agentic_engine: pre-compute GetAllAgentManifestFiles and
  GetAllAgentManifestFolders at registry construction time; zero-alloc reads
  on subsequent calls
- pkg/workflow/expression_nodes: replace fmt.Sprintf with string concat in
  StringLiteralNode, ComparisonNode, FunctionCallNode, and NotNode Render
  methods (1.5M+ allocs combined per benchmark run)
- pkg/workflow/jobs: pre-size strings.Builder in renderJob (8KB) and
  RenderToYAML (96KB) to reduce growths
- pkg/workflow/action_cache: add GetByCacheKey to reuse pre-computed keys
- pkg/workflow/action_resolver: use GetByCacheKey in ResolveSHA to avoid
  creating the cache key string twice per call

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/feede2cf-826c-4a45-bf18-c961ab18e5d9

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix performance regression in YAMLGeneration perf: optimize YAML generation hot paths (-7% latency, -10% allocations) May 1, 2026
Copilot AI requested a review from gh-aw-bot May 1, 2026 00:26
@pelikhan pelikhan marked this pull request as ready for review May 1, 2026 01:12
Copilot AI review requested due to automatic review settings May 1, 2026 01:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes YAML generation and related compilation hot paths by reducing allocations and repeated computations discovered via benchmarking/profiling.

Changes:

  • Replaces fmt.Sprintf with string concatenation in several frequently-called formatting/rendering paths.
  • Adds caching for engine manifest file/folder lists to avoid recomputation/allocation across calls.
  • Pre-sizes strings.Builder buffers in YAML job rendering to reduce reallocation churn.
  • Introduces ActionCache.GetByCacheKey and reuses a precomputed key in the resolver to avoid duplicate key allocations.
Show a summary per file
File Description
pkg/workflow/jobs.go Pre-grows YAML builders in job rendering to reduce reallocations.
pkg/workflow/expression_nodes.go Removes fmt.Sprintf usage in hot Render() methods to cut allocations.
pkg/workflow/agentic_engine.go Caches computed engine manifest folders/files for allocation-free repeated access.
pkg/workflow/action_cache.go Adds a raw-key lookup API to avoid recomputing cache keys.
pkg/workflow/action_resolver.go Reuses a single computed cache key and uses the new raw-key lookup.
pkg/actionpins/actionpins.go Replaces fmt.Sprintf with concatenation in hot formatting helpers.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 6/6 changed files
  • Comments generated: 4

Comment on lines +472 to +478
// Pre-compute and cache the manifest file/folder lists now that all engines are
// registered. These lists are derived solely from the registered engine set, which
// is fixed after construction. Pre-computing here guarantees thread-safe access:
// callers that read the cached slices later see a fully-initialised, immutable
// value and never trigger concurrent writes.
registry.cachedManifestFolders = registry.computeAllAgentManifestFolders()
registry.cachedManifestFiles = registry.computeAllAgentManifestFiles()
Comment on lines +307 to +316
// GetByCacheKey retrieves a cached entry by its pre-computed key.
// This avoids recomputing the cache key when the caller has already computed it.
func (c *ActionCache) GetByCacheKey(key string) (string, bool) {
entry, exists := c.Entries[key]
if !exists {
actionCacheLog.Printf("Cache miss for key=%s", key)
return "", false
}
actionCacheLog.Printf("Cache hit for key=%s, sha=%s", key, entry.SHA)
return entry.SHA, true
Comment on lines +307 to +316
// GetByCacheKey retrieves a cached entry by its pre-computed key.
// This avoids recomputing the cache key when the caller has already computed it.
func (c *ActionCache) GetByCacheKey(key string) (string, bool) {
entry, exists := c.Entries[key]
if !exists {
actionCacheLog.Printf("Cache miss for key=%s", key)
return "", false
}
actionCacheLog.Printf("Cache hit for key=%s, sha=%s", key, entry.SHA)
return entry.SHA, true
Comment on lines 148 to +153
func (f *FunctionCallNode) Render() string {
var args []string
for _, arg := range f.Arguments {
args = append(args, arg.Render())
}
return fmt.Sprintf("%s(%s)", f.FunctionName, strings.Join(args, ", "))
return f.FunctionName + "(" + strings.Join(args, ", ") + ")"
@github-actions github-actions Bot mentioned this pull request May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Hey @Copilot 👋 — great work tracking down the BenchmarkYAMLGeneration regression and addressing those allocation-heavy hot paths! The changes are well-scoped and the inline comments explaining the pre-allocation rationale are a nice touch.

One thing that would strengthen this PR:

  • Add or update tests — none of the six changed files have corresponding test-file changes. Given that the optimizations touch Render() methods in expression_nodes.go, cache lookup in action_resolver.go, and the new GetByCacheKey path in action_cache.go, even a small set of unit tests (or a benchmark test asserting the regression is gone) would give reviewers confidence the behaviour is unchanged and the perf gain is measurable.

If you'd like a hand, you can assign this prompt to your coding agent:

Add or update tests for the performance optimizations introduced in this PR:

1. pkg/actionpins/actionpins_test.go — verify FormatPinnedActionReference and FormatCacheKey still return the correct strings after the fmt.Sprintf → concatenation change.
2. pkg/workflow/expression_nodes_test.go — verify all four Render() methods (NotNode, FunctionCallNode, StringLiteralNode, ComparisonNode) produce correct output after the fmt.Sprintf → concatenation change.
3. pkg/workflow/action_cache_test.go — add a test for the new GetByCacheKey method covering cache-hit and cache-miss paths.
4. pkg/workflow/action_resolver_test.go — verify ResolveSHA uses the pre-computed cache key correctly (cache hit via GetByCacheKey).
5. Optionally, add a BenchmarkYAMLGeneration benchmark (or update an existing one) that asserts the regression is resolved and the new baseline is at or below 1.48ms.

Generated by Contribution Check · ● 1.2M ·

@pelikhan pelikhan merged commit c05192a into main May 1, 2026
121 checks passed
@pelikhan pelikhan deleted the copilot/performance-regression-yamlgeneration branch May 1, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[performance] Regression in YAMLGeneration: +18.8% slower

4 participants