Skip to content

perf: fix 104% regression in ExtractWorkflowNameFromFile by reducing scanner buffer allocation#30706

Merged
pelikhan merged 2 commits into
mainfrom
copilot/fix-extract-workflow-name-performance
May 7, 2026
Merged

perf: fix 104% regression in ExtractWorkflowNameFromFile by reducing scanner buffer allocation#30706
pelikhan merged 2 commits into
mainfrom
copilot/fix-extract-workflow-name-performance

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

fastParseTitleFromReader was allocating a 64 KB heap buffer on every call via scanner.Buffer(make([]byte, 64*1024), 1024*1024), even though the function only needs to scan a handful of lines to locate the H1 header.

Change

Reduce the initial buffer from 64 KB to 4 KB (matching bufio.Scanner's default), keeping the 1 MB max token size for files with large frontmatter or base64-encoded lines:

// Before
scanner.Buffer(make([]byte, 64*1024), 1024*1024)

// After
scanner.Buffer(make([]byte, 4*1024), 1024*1024)

Results

ns/op B/op
Before ~25,000 65,798
After ~7,600 4,358
Δ −70% −93%

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 gh repo view --json owner,name --jq .owner.login + "/" + .name ache/go/1.25.8/x64/bin/node ub/workflows (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 (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 .cfg 64/pkg/tool/linu--git-dir gh run te 'scripts/**/*.js' --ignore-path .prettierignore --log-level=error 4 k/gh-aw/gh-aw/actions/node_modules/.bin/node test-logs/run-4 LsRemoteWithReal-1 64/pkg/tool/linuxterm-color /bin/sh (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 (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name -bool -buildtags /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc /opt/hostedtoolc-buildtags -ato�� js/**/*.json' ---errorsas -buildtags /usr/bin/infocmp-nilfunc -errorsas -ifaceassert -nilfunc infocmp (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 --show-toplevel 1/x64/bin/node /usr/bin/git licyMinIntegritygit -buildtags /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git -stringintconv -tests 1/x64/bin/node 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 -v 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 ll-sweep (enforce_all)' ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /home/REDACTED/.cargo/bin/sh l 2242204/b005/vetrev-parse sv 249045/b410/importcfg -c pkg/mod/github.com/aymanbagabas/go-udiff@v0.4.1/lcs/common.go pkg/mod/github.com/aymanbagabas/go-udiff@v0.4.1/lcs/doc.go 1/x64/bin/node 5751-14194/test-infocmp origin ache/go/1.25.8/xxterm-color 1/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv ithub-script/git/ref/tags/v9 git bject.type] | @tsv /tmp/gh-aw-test-git l /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git /tmp/TestGuardPogit rev-parse /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel infocmp /usr/bin/git xterm-color ache/go/1.25.8/xrev-parse /usr/bin/git git rev-�� /ref/tags/v9 git sv --show-toplevel node /usr/bin/infocmp--show-toplevel gh (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 runs/20260507-000006-16646/test-3059949638/.github/workflows /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet t runs/20260506-23gh -buildtags kflows/my-workfl/repos/actions/github-script/git/ref/tags/v9 infocmp -1 xterm-color /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /usr/bin/git runs/20260506-23git -buildtags /opt/hostedtoolc--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv k/gh-aw/gh-aw/.github/workflows/artifacts-summary.md /opt/hostedtoolc-parallel=4 /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link w/js/**/*.json' git -buildtags x_amd64/link /opt/hostedtoolcache/go/1.25.8/x--jq -o /tmp/go-build628249045/b453/testutil.test s/test.md /usr/bin/git -s -w -buildmode=exe git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv tagedFiles906553447/001/workflow.md mDRmydbNI-g3 /usr/bin/git for-each-ref (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 git /usr/bin/git /tmp/file-trackegh git /usr/bin/git git rev-�� ithub-script/git/ref/tags/v9 git bject.type] | @tsv n-dir/git x_amd64/link (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)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv 2053956847/001' 2053956847/001' 64/bin/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv 571914875/001' 571914875/001' in/dist/gh-gpgsign/gh-gpgsign-linux-x86_64 ader (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9.0.0
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv add-source-path-3166406313/.github/workflows (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv ithub/workflows /tmp/go-build1272242204/b022/vet.cfg /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (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 --show-toplevel ache/go/1.25.8/xsecurity /usr/bin/gh SameOutput209329gh --write 64/pkg/tool/linu/repos/actions/github-script/git/ref/tags/v9 gh api /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git mSZX/tMRKNmJ9hTFgit cfg /opt/hostedtoolc--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 /tmp/TestCompileErrorFormatting2558929011/001 remote /usr/bin/git --show-toplevel (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 node /usr/bin/infocmp SameOutput209329infocmp --write 1/x64/bin/node infocmp -1 xterm-color sh /usr/bin/git ithub/workflows/git ache/go/1.25.8/xrev-parse /opt/hostedtoolc--show-toplevel git (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 JN/8yS8ifIPgkZfN4pT7DML/dEEaya72B73r4eDnuBW3 /usr/bin/git -bool -buildtags /opt/hostedtoolc--show-toplevel git rev-�� /ref/tags/v9 /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linuowner/repo sv -bool -buildtags 64/pkg/tool/linuxterm-color gh (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 runs/20260507-000006-16646/test-3059949638/.github/workflows rev-parse /usr/bin/infocmp /tmp/go-build127git -trimpath 2242204/b352/vet--show-toplevel infocmp -1 -aw/git/ref/tags/v2.0.0 /opt/hostedtoolcache/go/1.25.8/x-buildtags bject.type] | @tsv runs/20260506-23git -buildtags layTitle git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv ErrorFormatting2558929011/001 /opt/hostedtoolcache/go/1.25.8/xowner=github /opt/hostedtoolcache/node/24.14.-f w/js/**/*.json' git -buildtags x_amd64/link node /tmp�� s/test.md x_amd64/link /usr/bin/git /tmp/gh-aw-test-git show /usr/lib/git-cor--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv xterm-color git /usr/bin/git --symref l /usr/bin/git git conf�� --get remote.origin.url om/testorg/testrepo.git -silent >/dev/nugit (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 --show-toplevel -extld=gcc /opt/hostedtoolcache/node/24.14.1/x64/bin/node path .prettieriggit config /usr/bin/git /opt/hostedtoolcache/node/24.14.1/x64/bin/node /tmp�� secrets.TOKEN git /usr/bin/git ub/workflows config 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/aws-actions/configure-aws-credentials/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel /tmp/go-build628249045/b442/sliceutil.test /usr/bin/git -test.paniconexigit 249045/b463/_tesrev-parse /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link /usr/bin/git /tmp/go-build628gh -importcfg /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/compile-insgh 249045/b467/_tesapi /opt/hostedtoolc/repos/actions/github-script/git/ref/tags/v9 git rev-�� /ref/tags/v9 /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link sv /tmp/go-build628git -importcfg /usr/bin/git infocmp (http block)
  • https://api.github.com/repos/azure/login/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/azure/login/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/TestGuardPogit (http block)
  • https://api.github.com/repos/docker/login-action/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/docker/login-action/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/TestGuardPogit rev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/infocmp thImports1487447infocmp remote /usr/bin/git infocmp (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 /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/gh 1926734701 ache/go/1.25.8/xapi /home/REDACTED/wor/repos/actions/github-script/git/ref/tags/v9 gh api /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git --write =develop 1/x64/bin/node 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 user.email test@example.com /usr/bin/git go1.25.8 -c=4 -nolocalimports git comm�� -m Initial commit /usr/bin/git xterm-color (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 /home/REDACTED/work/gh-aw/gh-aw/.github/workflows/api-consumption-report.md git /opt/hostedtoolcache/node/24.14.1/x64/bin/node th .prettierignogit (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-29 (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-06 (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-02-05 (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 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 .cfg 64/pkg/tool/linux_amd64/vet http.https://gitgit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name x_amd64/vet k/gh-aw/node_modules/.bin/node 01 onpins 64/pkg/tool/linuuser.name git ache�� 1066063217 64/pkg/tool/linuremote.origin.url ache/node/24.14.1/x64/bin/npm (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 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name test@example.com son ignore (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1234567890
    • Triggering command: /usr/bin/gh gh api repos/{owner}/{repo}/actions/runs/1234567890 --jq {databaseId: .id, number: .run_number, url: .html_url, status: .status, conclusion: .conclusion, workflowName: .name, workflowPath: .path, createdAt: .created_at, startedAt: .run_started_at, updatedAt: .updated_at, event: .event, headBranch: .head_branch, 78337544/001' 78337544/001' (http block)
    • Triggering command: /usr/bin/gh gh api repos/{owner}/{repo}/actions/runs/1234567890 --jq {databaseId: .id, number: .run_number, url: .html_url, status: .status, conclusion: .conclusion, workflowName: .name, workflowPath: .path, createdAt: .created_at, startedAt: .run_started_at, updatedAt: .updated_at, event: .event, headBranch: .head_branch, 57510322/001' 57510322/001' (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 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name x_amd64/vet x_amd64/compile ignore (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 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 .cfg 64/pkg/tool/linux_amd64/vet http.https://gitgit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name x_amd64/vet k/node_modules/.bin/node (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 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 .cfg 64/pkg/tool/linux_amd64/vet http.https://gitgit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name Test User e_modules/.bin/node (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 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 LsRemoteWithRealGitcustom_branch571914875/001' 64/pkg/tool/linux_amd64/vet http.https://gitgit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name test@example.com es/.bin/node (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 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 --global 64/pkg/tool/linux_amd64/vet http.https://gitgit (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name x_amd64/vet in/node (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path (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 (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 (http block)
  • https://api.github.com/repos/github/gh-aw/contents/.github/workflows/shared/reporting.md
    • Triggering command: /tmp/go-build628249045/b404/cli.test /tmp/go-build628249045/b404/cli.test -test.testlogfile=/tmp/go-build628249045/b404/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true (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 git /usr/bin/git /tmp/gh-aw-test-du remote 0"}} git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linuconntrack /usr/bin/infocmp -bool -buildtags /opt/hostedtoolc--show-toplevel infocmp (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 te 'scripts/**/*.js' --ignore-pa-c=4 64/pkg/tool/linux_amd64/vet k/node_modules/.bin/node itbranch_with_hygit itbranch_with_hyrev-parse 64/pkg/tool/linu--show-toplevel bash k/gh�� 0006-16646/test-1528348220/.github/workflows on 64/pkg/tool/linux_amd64/compile /../../.prettierinfocmp erignore ache/go/1.25.8/xxterm-color 64/pkg/tool/linux_amd64/compile (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 (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 3167341642/.github/workflows (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 (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 repos/{owner}/{r--detach --jq _modules/.bin/sh 78337544/001' 78337544/001' (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 /tmp/gh-aw-test-runs/20260506-235751-14194/test-3748782400/.github/workflows s/12345/artifacts es/.bin/sh (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 (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 --show-toplevel (http block)
  • https://api.github.com/repos/google-github-actions/auth/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/google-github-actions/auth/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git --show-toplevel /opt/hostedtoolcrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git /ref/tags/v9 git sv git (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 te 'scripts/**/*.js' --ignore-path .prettierignore --log-level=error 64/pkg/tool/linutest@example.com Name,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle get .cfg 64/pkg/tool/linuxterm-color 64/pkg/tool/linux_amd64/vet k/gh�� --noprofile on (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 ub/workflows (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 (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc /opt/hostedtoolc-trimpath -ato�� js/**/*.json' ---p -buildtags x_amd64/asm -errorsas -ifaceassert -nilfunc x_amd64/asm (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc /opt/hostedtoolc-buildtags -ato�� js/**/*.json' ---errorsas l /usr/bin/git -errorsas -ifaceassert -nilfunc 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 (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name runs/20260506-235751-14194/test-- s /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet l -ifaceassert -nilfunc /opt/hostedtoolc-test.v=true -ato�� js/**/*.json' ---test.timeout=10m0s -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git (http block)
  • https://api.github.com/repos/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch 1641638331/custom/workflows 64/pkg/tool/linu--auto cfg (http block)

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

…fix perf regression

The scanner was allocating a 64KB initial buffer on every call to
fastParseTitleFromReader, causing ~65KB of heap allocation per invocation.
Reduce the initial buffer to 4KB (matching the default bufio.Scanner size)
while keeping the 1MB max token size for large frontmatter blocks.

Benchmark improvement:
- Before: ~25,000 ns/op, 65,798 B/op
- After:  ~7,600 ns/op,  4,358 B/op (~70% faster, ~93% less memory)

Fixes the 104.8% regression in BenchmarkExtractWorkflowNameFromFile.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/efb077b2-543e-4ada-93aa-f313d7239926

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix performance regression in ExtractWorkflowNameFromFile perf: fix 104% regression in ExtractWorkflowNameFromFile by reducing scanner buffer allocation May 7, 2026
Copilot AI requested a review from gh-aw-bot May 7, 2026 00:03
@pelikhan pelikhan marked this pull request as ready for review May 7, 2026 01:18
Copilot AI review requested due to automatic review settings May 7, 2026 01:18
@pelikhan pelikhan merged commit 61bec41 into main May 7, 2026
@pelikhan pelikhan deleted the copilot/fix-extract-workflow-name-performance branch May 7, 2026 01:18
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

Reduces per-call heap allocation overhead in fastParseTitleFromReader (used by workflow name extraction) by lowering the initial bufio.Scanner buffer size while keeping a large max token limit for long lines/frontmatter.

Changes:

  • Reduce bufio.Scanner initial buffer from 64 KB to 4 KB in fastParseTitleFromReader.
  • Keep the max scan token size at 1 MB to preserve support for unusually large frontmatter/lines.
  • Expand comments explaining the rationale for the buffer sizing.
Show a summary per file
File Description
pkg/cli/workflows.go Lowers initial scanner buffer allocation to reduce allocations/CPU in workflow title parsing while retaining a 1 MB max token limit.

Copilot's findings

Tip

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

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

Comment thread pkg/cli/workflows.go
scanner.Buffer(make([]byte, 64*1024), 1024*1024)
// Use a small initial buffer (4 KB, matching the default scanner allocation)
// but allow growth up to 1 MB to handle files with large frontmatter values
// or long base64-encoded lines. Keeping the initial size small avoids a
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 ExtractWorkflowNameFromFile: 104.8% slower

4 participants