Reduce ExtractWorkflowNameFromFile overhead in CLI workflow title parsing#44604
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
ExtractWorkflowNameFromFile overhead in CLI workflow title parsing
|
PR Triage - Run 29041860272. Category: chore | Risk: Low | Score: 28/100 | Action: defer. DRAFT. Micro hot-path optimization in ExtractWorkflowNameFromFile (8+/5-, 1 file). No behavior change. Undraft when ready; low priority.
|
This comment has been minimized.
This comment has been minimized.
🤖 PR Triage — Run §29061171191
Reduce ExtractWorkflowNameFromFile overhead. DRAFT, 1 file, 8 additions. Minor perf chore. Low priority.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
|
Thanks for the performance optimization in One suggestion before merging:
If you would like a hand:
|
|
@copilot extract the first header h1, h2, or h3 as the title |
There was a problem hiding this comment.
Pull request overview
This PR optimizes CLI workflow title parsing by tightening the hot path in fastParseTitleFromReader, aiming to reduce per-line overhead in ExtractWorkflowNameFromFile without changing parsing semantics.
Changes:
- Switched from
scanner.Text()+strings.*operations toscanner.Bytes()+bytes.*operations to reduce transient allocations during line scanning. - Preserved existing behavior for frontmatter delimiter detection (
---) and H1 title extraction (#), while keeping early-exit scanning.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/workflows.go | Reworks title scanning to operate on byte slices (bytes.TrimSpace/HasPrefix/Equal) instead of strings to reduce per-line work in the title extraction hot path. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
| frontmatterDelimiter := []byte("---") | ||
| h1Prefix := []byte("# ") |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
ExtractWorkflowNameFromFileshowed a measurable regression versus historical benchmark levels, with time spent in line-by-line title extraction. This change tightens the hot path infastParseTitleFromReaderto reduce per-line work without altering parsing behavior.Hot-path optimization in title scanning
scanner.Text()+strings.TrimSpace/HasPrefixwithscanner.Bytes()+bytes.TrimSpace/HasPrefix/Equal.---) and H1 extraction (#), while reducing transient allocations.Scope and behavior
/pkg/cli/workflows.goinfastParseTitleFromReader.