Skip to content

perf: eliminate redundant file read and frontmatter re-parse in buildJobs#29410

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-regression-in-compilesimpleworkflow
May 1, 2026
Merged

perf: eliminate redundant file read and frontmatter re-parse in buildJobs#29410
pelikhan merged 3 commits intomainfrom
copilot/fix-regression-in-compilesimpleworkflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

CompileSimpleWorkflow regressed ~16.7% (1.47ms → 1.71ms). Profiling identified two redundant allocation hot spots per compilation.

Changes

  • Eliminate redundant disk I/O in buildJobs — the function was calling os.ReadFile + parser.ExtractFrontmatterFromContent on every compilation to obtain frontmatter, despite data.RawFrontmatter already holding the identical parsed result. The consumers (needsRoleCheck, hasWorkflowRunTrigger) only inspect event keys in the on field, which are unaffected by preprocessScheduleFields.

    // Before: re-read file + re-parse YAML on every compile
    if diskContent, err := os.ReadFile(markdownPath); err == nil { ... }
    parser.ExtractFrontmatterFromContent(rawContent)
    
    // After: use already-parsed data
    frontmatter := data.RawFrontmatter
  • Skip unnecessary map copy in copyFrontmatterWithoutInternalMarkers — the function always allocated a new map even when no __gh_aw_native_label_filter__ markers were present. Added a fast-path check that returns the original map directly for the common case (workflows without label-filtered events).

Benchmark

Metric Before After Δ
Time 1,505 ns/op 1,421 ns/op −5.6%
Memory 1,065 kB/op 1,041 kB/op −2.3%
Allocations 5,508/op 5,062/op −8.1%

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 x_amd64/link GOINSECURE GOMOD GOMODCACHE x_amd64/link env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE N_/MhA652aEkSuR8NKQxPfr/feDwSjXStImIOC-NY5wN (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 1429-34813/test-source-field-variant-502532070/.github/workflows GO111MODULE cfg 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 "prettier" --cheGOINSECURE node 64/bin/go --write ../../../**/*.js-unsafeptr=false 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 list --repo /usr/bin/git --json name,path,state ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel go /usr/bin/git 8496/001/stabili/bin/sh GO111MODULE cfg 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 --show-toplevel -goversion /usr/bin/git -c=4 -nolocalimports -importcfg git rev-�� --show-toplevel /home/REDACTED/work/gh-aw/gh-aw/pkg/stats/spec_test.go /usr/bin/git -json GO111MODULE 64/bin/go git (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 go t.go 1/x64/bin/node GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/xowner/repo -has�� vaScript3235845378/001/test-empty-frontmatter.md GO111MODULE 281324/b413/importcfg.link GOINSECURE GOMOD GOMODCACHE jqWy3vqedtzVW/U8nt9zLENvjKcOLdPac7/zhJWMtxx0i81O5psxxYi/jNeV8hZj-extld=gcc (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel rtcfg /usr/bin/git dcfg GO111MODULE erutil.test git rev-�� --show-toplevel erutil.test /usr/bin/git 281324/b412/_pkggit GO111MODULE 281324/b412=> git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv /ref/tags/v9 git sv k/gh-aw/gh-aw/.ggit config /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git /tmp/gh-aw-test-git git om/org1/repo.git--show-toplevel 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 --noprofile 64/src/cmd/inter-d ache/go/1.25.8/x168.63.129.16 (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -unreachable=false /tmp/go-build3026739227/b072/vet.cfg tnet/tools/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/vendor/golang.org/x/term/term.go e/git-remote-https -errorsas -ifaceassert -d/pprof e/git-remote-https -o om/github/gh-aw -d/pprof tnet/tools/bash -p cmd/vendor/githurev-parse 84f06d074c4306ae--show-toplevel bash (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 go /usr/bin/git artifacts-summargit GO111MODULE /opt/hostedtoolcache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel go /usr/bin/git '/tmp/TestParseDgit '/tmp/TestParseDrev-parse /opt/hostedtoolc--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 # Confirm that the mysql service is running and that mysqladmin # exists as it is needed fogit (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi alternatives.tar /home/REDACTED/go/bin/bash go1.25.8 -c=4 -nolocalimports bash --no�� ateYAML /opt/hostedtoolcache/go/1.25.8/x64/src/cmd/vendor/github.com/google/pprof/profile/encode.go kflow.test (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv --noprofile (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 alternatives.tar.0 -C 64/pkg/tool/linux_amd64/cgo alternatives -c=4 -nolocalimports 64/pkg/tool/linux_amd64/cgo -w res_import_test.go t_schema_test.go 64/pkg/tool/linux_amd64/vet -nxv (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/lib/git-core/git-remote-https -json GO111MODULE ache/go/1.25.8/x--show-toplevel /usr/lib/git-core/git-remote-https http�� REDACTED go /usr/bin/git edOutput15509620git GO111MODULE ache/go/1.25.8/x--show-toplevel 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 dpkg.diversions.0 /var/lib/dpkg/diversions 64/pkg/tool/linux_amd64/compile go1.25.8 -c=4 -nolocalimports 64/pkg/tool/linux_amd64/compile -w -t security 64/pkg/tool/linux_amd64/compile OUTPUT -d 168.63.129.16 64/pkg/tool/linux_amd64/compile (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-001429-34813/test-1765432040 s/5/artifacts /usr/bin/git -json GO111MODULE 64/bin/go git init�� GOMODCACHE 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 xterm-color go /usr/bin/git itbranch_with_hygit itbranch_with_hyrev-parse ache/go/1.25.8/x--show-toplevel git arch�� --remote=REDACTED v1.0.0 /usr/bin/git edOutput15509620git GO111MODULE til.test 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 --noprofile 64/src/debug/gos-d ndor/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 -unreachable=false /tmp/go-build3026739227/b105/vetforeach(ini_get_all("session") as $k => $v) echo "$k=".$v["localrev-parse ash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -bool ache/go/1.25.8/x64/src/cmd/vendor/github.com/google/pprof/internal/symbolizer/symbolizer.go e/git -errorsas -ifaceassert -nilfunc e/git -o /tmp/go-build53808800/b203/_pkg_.a -trimpath ash -p cmd/vendor/githurev-parse -lang=go1.25 bash (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 /tmp/TestGuardPolicyMinIntegrityOnlyrepos_only_without_min-integrity2881662435/0-errorsas remote /usr/bin/infocmp /tmp/go-build195git -trimpath 64/bin/go infocmp -1 mpleWorkflow895106295/001 go 281324/b474/vet.cfg -json GO111MODULE 64/bin/go git (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/git mLsRemoteWithReagit mLsRemoteWithRearev-parse 64/bin/go git rev-�� --show-toplevel go /usr/bin/git edOutput33845629git GO111MODULE ache/go/1.25.8/x--show-toplevel 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 k/gh-aw/gh-aw/pkg/stringutil/ansi.go k/gh-aw/gh-aw/pkg/stringutil/identifiers.go /usr/bin/git /tmp/go-build195git -trimpath 64/bin/go git -C ansitiveImports3247249303/001 rev-parse /usr/bin/git -json GO111MODULE 64/bin/go 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 /tmp/TestGuardPolicyBlockedUsersCommaSeparatedCompiledOutput3006505098/001 (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 ned-imports-enabled-with-env-template-expressions-in-body.md 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 22/xQe5f0wJO56wlipN0mlS/Z5vIoFqE--revs env -json 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/linux_amd64/link env 78/001/test-empty-frontmatter.md GO111MODULE rtcfg.link GOINSECURE GOMOD GOMODCACHE nt9zLENvjKcOLdPac7/zhJWMtxx0i81O5psxxYi/jNeV8hZj-extld=gcc (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE 64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/link env 1317731938/custom/workflows GO111MODULE rtcfg.link GOINSECURE GOMOD GOMODCACHE odp3IL84tZKq5R-8Dk/Exs2fuW_hbdM5nZZzdgr/Win8VWOQrev-parse (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/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env -json GO111MODULE x_amd64/link GOINSECURE GOMOD GOMODCACHE x_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE onpins.test GOINSECURE GOMOD GOMODCACHE onpins.test 6528�� 3483171546/.github/workflows GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (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/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu^remote\..*\.gh-resolved$ env tdrain.test GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json 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)
  • 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 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 78/001/test-empty-frontmatter.md GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 -json GO111MODULE k GOINSECURE GOMOD GOMODCACHE go (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 x_amd64/link GOINSECURE GOMOD GOMODCACHE x_amd64/link env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE 06/m1mI9m8ZybBw5VAsfaec/Pi1C9UCl-test.v=true (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linutest@example.com env 1317731938/custom/workflows GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 l_test.go ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 2870584935 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 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 6 GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env 3910605757 GO111MODULE 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-build165281324/b404/cli.test /tmp/go-build165281324/b404/cli.test -test.testlogfile=/tmp/go-build165281324/b404/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE 9126699/b403/impGO111MODULE -c k/gh-aw/gh-aw/pkGOINSECURE GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcGO111MODULE (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 --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /usr/bin/git 1765432040 GO111MODULE /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel go (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 -json GO111MODULE tartedAt,updatedAt,event,headBranch,headSha,displayTitle GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE /opt/hostedtoolcache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 0384�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 -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/v2.0.0 --jq [.object.sha, .object.type] | @tsv -json 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 iant-3513486538/.github/workflows GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go 9279�� -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 -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go 0384�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 y.md GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linuupstream (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 x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (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 8496/001/stability-test.md GO111MODULE cfg GOINSECURE GOMOD GOMODCACHE go (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-### 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch 1317731938 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)

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

…Jobs

The buildJobs function was reading the workflow file from disk and
re-parsing the YAML frontmatter on every compilation even though the
WorkflowData struct already contains the pre-parsed RawFrontmatter.

This redundant work (os.ReadFile + parser.ExtractFrontmatterFromContent)
was eliminated by using data.RawFrontmatter directly. The functions that
consume frontmatter in buildPreActivationAndActivationJobs only inspect
event key presence in the 'on' field, which is identical between
RawFrontmatter and a fresh parse (preprocessScheduleFields only changes
cron values inside schedule entries, not event keys).

Also optimize copyFrontmatterWithoutInternalMarkers to skip the map copy
entirely when no __gh_aw_native_label_filter__ markers are present. This
is the common case for workflows without label-filtered events.

Benchmark improvement on CompileSimpleWorkflow:
  Before: 1,505 ns/op  1,065 kB/op  5,508 allocs/op
  After:  1,421 ns/op  1,041 kB/op  5,062 allocs/op
  Improvement: ~5.6% faster, 8.1% fewer allocations

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/1b1c547e-787c-4039-b0de-e505bc033638

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix performance regression in CompileSimpleWorkflow perf: eliminate redundant file read and frontmatter re-parse in buildJobs May 1, 2026
Copilot AI requested a review from gh-aw-bot May 1, 2026 00:17
@pelikhan pelikhan marked this pull request as ready for review May 1, 2026 00:22
Copilot AI review requested due to automatic review settings May 1, 2026 00:22
@github-actions github-actions Bot mentioned this pull request May 1, 2026
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

This PR optimizes compilation performance by removing redundant frontmatter work during job construction and avoiding unnecessary allocations when copying frontmatter for validation.

Changes:

  • Reuse WorkflowData.RawFrontmatter in buildJobs to avoid re-reading the workflow file and re-parsing YAML each compilation.
  • Add a fast-path in copyFrontmatterWithoutInternalMarkers to return the original map when no internal marker fields are present.
  • Minor allocation reductions by pre-sizing copied maps.
Show a summary per file
File Description
pkg/workflow/compiler_jobs.go Stops re-reading and re-parsing frontmatter in buildJobs, using data.RawFrontmatter instead.
pkg/workflow/compiler_orchestrator_frontmatter.go Adds a fast-path to skip allocating/copying frontmatter when no internal marker fields exist.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread pkg/workflow/compiler_jobs.go Outdated
Comment on lines +184 to +185
// The checks in buildPreActivationAndActivationJobs only inspect the "on" event keys,
// which are unaffected by preprocessScheduleFields or internal label-filter markers.
Comment on lines +154 to +160
// Fast path: check if any internal markers are present before allocating a copy.
// Markers only appear in on.issues, on.pull_request, and on.discussion sub-maps.
hasMarkers := false
if onValue, hasOn := frontmatter["on"]; hasOn {
if onMap, ok := onValue.(map[string]any); ok {
for _, eventKey := range []string{"issues", "pull_request", "discussion"} {
if sectionValue, exists := onMap[eventKey]; exists {
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented May 1, 2026

@copilot review all comments

…marker handling

- Update comment in buildJobs to accurately describe that RawFrontmatter is
  the already-preprocessed form (preprocessScheduleFields has already run),
  removing the misleading claim about keys being "unaffected" by preprocessing.

- Add issue_comment to both the fast-path marker scan and the removal loop in
  copyFrontmatterWithoutInternalMarkers, consistent with how frontmatter_extraction_yaml.go
  handles the __gh_aw_native_label_filter__ marker for all four event types.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6b8f05dd-16ac-4733-aa46-90c1bc67e8cc

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 1, 2026

@copilot review all comments

Both reviewer comments addressed in 3ddd702:

  1. compiler_jobs.go comment: Updated to accurately state that RawFrontmatter is already the preprocessed form (after preprocessScheduleFields has run), removing the misleading "unaffected by preprocessScheduleFields" claim.

  2. copyFrontmatterWithoutInternalMarkers: Added issue_comment to both the fast-path marker scan and the removal loop, consistent with how frontmatter_extraction_yaml.go handles __gh_aw_native_label_filter__ across all four event types (issues, pull_request, discussion, issue_comment).

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)
  • 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 (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 (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 (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 (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 (http block)

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

Copilot AI requested a review from pelikhan May 1, 2026 01:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Hey @Copilot 👋 — great work tracking down the CompileSimpleWorkflow regression and quantifying the fix with benchmark data! The two-pronged approach (eliminating the redundant os.ReadFile/re-parse and adding the fast-path in copyFrontmatterWithoutInternalMarkers) is clean and well-motivated.

A couple of things worth addressing before this lands:

  • Unfocused diff — the PR includes changes to 7 .github/workflows/*.lock.yml files that are not mentioned in the description and appear unrelated to the performance fix. If these were incidentally modified during the agent run, they should be reverted or split into a separate PR so reviewers can focus on the performance work.
  • No tests — the benchmark numbers look compelling, but neither compiler_jobs.go nor compiler_orchestrator_frontmatter.go has corresponding test coverage added. Consider adding or updating unit tests for needsRoleCheck/hasWorkflowRunTrigger (now reading from data.RawFrontmatter) and the fast-path in copyFrontmatterWithoutInternalMarkers.

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

In the PR branch for "perf: eliminate redundant file read and frontmatter re-parse in buildJobs":

1. Revert any changes to .github/workflows/*.lock.yml files that are not directly caused by the performance fix in pkg/workflow/compiler_jobs.go and pkg/workflow/compiler_orchestrator_frontmatter.go. These should be committed separately.

2. Add unit tests in the appropriate *_test.go file(s) for:
   - pkg/workflow/compiler_jobs.go: verify that needsRoleCheck and hasWorkflowRunTrigger correctly read event keys from data.RawFrontmatter (rather than re-reading from disk).
   - pkg/workflow/compiler_orchestrator_frontmatter.go: verify the fast-path in copyFrontmatterWithoutInternalMarkers — (a) returns the original map when no __gh_aw_native_label_filter__ markers are present, and (b) returns a filtered copy when markers are present.

Generated by Contribution Check · ● 1.2M ·

@pelikhan pelikhan merged commit a5f9b87 into main May 1, 2026
26 checks passed
@pelikhan pelikhan deleted the copilot/fix-regression-in-compilesimpleworkflow 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 CompileSimpleWorkflow: +16.7% slower

4 participants