Skip to content

Improve ExtractWorkflowNameFromFile hot-path parsing to recover benchmark regression#45225

Draft
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-performance-regression-extract-workflow-name
Draft

Improve ExtractWorkflowNameFromFile hot-path parsing to recover benchmark regression#45225
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-performance-regression-extract-workflow-name

Conversation

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

BenchmarkExtractWorkflowNameFromFile regressed materially versus historical baseline despite low allocations. This change reduces per-line parsing overhead in the workflow title scanner while preserving existing parsing behavior for whitespace-tolerant markdown/frontmatter inputs.

  • Parser hot path simplification

    • Updated fastParseTitleFromReader to check raw scanned bytes first for:
      • frontmatter delimiters (---)
      • H1/H2/H3 prefixes
    • Falls back to trimmed-line checks only when needed, avoiding unconditional TrimSpace/prefix work on every line.
  • Behavior-preserving helper extraction

    • Added focused helpers to make branch logic explicit and cheap:
      • isFrontmatterDelimiter([]byte)
      • extractHeadingTitle([]byte) (string, bool)
  • Edge-case coverage for whitespace-tolerant parsing

    • Added a targeted test case covering:
      • frontmatter delimiters with surrounding whitespace
      • indented H1 title extraction
if title, ok := extractHeadingTitle(line); ok {
	return title, nil
}
if trimmed := bytes.TrimSpace(line); !bytes.Equal(trimmed, line) {
	if title, ok := extractHeadingTitle(trimmed); ok {
		return title, nil
	}
}

Copilot AI and others added 2 commits July 13, 2026 08:01
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix performance regression in ExtractWorkflowNameFromFile Improve ExtractWorkflowNameFromFile hot-path parsing to recover benchmark regression Jul 13, 2026
Copilot AI requested a review from pelikhan July 13, 2026 08:14
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for documenting the benchmark regression and the intended parser optimization clearly. The core change is on-topic, but this PR is not focused yet because it also updates a very large set of .lock.yml workflow artifacts unrelated to the parser hot path, which makes review harder.

Please split this into a narrowly scoped PR that contains only the parser/test changes, or clearly justify why the lockfile churn is required for this change.

You are updating PR #45225 for gh-aw.

Goal: make the PR tightly focused.

Tasks:
1. Remove unrelated `.github/workflows/*.lock.yml` changes from this PR unless they are strictly required by the parser change.
2. Keep only the source/code/test changes directly related to `ExtractWorkflowNameFromFile` performance and behavior preservation.
3. Ensure the PR description explains:
   - what regressed,
   - why this implementation fixes it,
   - what test coverage was added.
4. Recalculate the diff so reviewers can evaluate one concern only.

Constraints:
- Do not add new dependencies.
- Preserve or improve the existing targeted test coverage.
- Prefer a small, reviewable diff.

Generated by ✅ Contribution Check · 101 AIC · ⌖ 9.12 AIC · ⊞ 6.2K ·

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: 24.3% slower

2 participants