[repository-quality] Repository Quality Improvement Report — Performance (2026-06-26) #41712
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-06-27T13:39:29.582Z.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🎯 Repository Quality Improvement Report — Performance
Analysis Date: 2026-06-26
Focus Area: Performance
Strategy Type: Standard (random=62, tier 60–89)
Custom Area: No
Executive Summary
This run examined startup cost, hot-path regexp usage, and benchmark regression detection. Three production gaps were found: the 648 KB
mainWorkflowSchemais unmarshalled up to 4 times per process (a sharedgetParsedSchemaDoc()already exists butschema_deprecation.gobypasses it);applySanitizePatternrecompiles a dynamic regexp on every call with no cache; andpermissions_toolset_data.goeagerly JSON-parses toolset data ininit()for all commands including those that never validate permissions. The bench CI job produces artifacts but has no regression threshold — a 2× slowdown merges silently.Full Analysis
Current State Assessment
init()functions in production codeinit()doing eager JSON unmarshalpermissions_toolset_data.go)mainWorkflowSchema(648 KB) parse instances/processregexp.MustCompilein function bodies (dynamic)sync.Oncelazy-init usagesKey Findings
[HIGH]
schema_deprecation.goindependently parsesmainWorkflowSchematwice (lines 43 and 168) under separatesync.Onceblocks.getParsedSchemaDoc(mainWorkflowSchema)in the same package caches this parse — neither deprecation function uses it.[HIGH]
pkg/stringutil/sanitize.go:143—regexp.MustCompile('[^' + allowedChars + ']+')runs on everyapplySanitizePatterncall. There are at most 4 distinctallowedCharsvalues in practice; async.Mapcache would make compilation a one-time cost.[MEDIUM]
pkg/workflow/permissions_toolset_data.go:39—init()unmarshals 6.6 KB embedded JSON unconditionally at startup. Commands likegh aw run,gh aw compile, andgh aw logsnever touchtoolsetPermissionsMap.[MEDIUM] CI
benchjob (.github/workflows/cgo.yml~line 906) saves results as artifacts but never invokesbenchstator fails on regression.[LOW]
safe_update_enforcement.go:138andruntime_definitions.go:179both iterateknownRuntimesin separateinit()calls;runtimeActionRepos map[string]boolduplicates a subset ofactionRepoToRuntime.🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Task 1: Share parsed schema doc in
schema_deprecation.goPriority: High | Effort: Small
Code Region:
pkg/parser/schema_deprecation.goReplace the two independent
json.Unmarshal([]byte(mainWorkflowSchema), &schemaDoc)calls inGetMainWorkflowDeprecatedFields(line ~43) andGetMainWorkflowDeprecatedFieldsDeep(line ~168) with calls togetParsedSchemaDoc(mainWorkflowSchema)(same package,schema_compiler.go). Type-assert theanyresult tomap[string]any. The result-cachingsync.Onceblocks for the deprecated-fields slices themselves should remain; only the JSON-parse step is removed.Acceptance Criteria:
getParsedSchemaDoc(mainWorkflowSchema)instead of their ownjson.Unmarshalgo test ./pkg/parser/...passesmake lintpassesTask 2: Cache dynamic regexp in
applySanitizePatternPriority: High | Effort: Small
Code Region:
pkg/stringutil/sanitize.goAdd
var sanitizePatternCache sync.Mapat package level. InapplySanitizePattern(line 142), load from the cache keyed byallowedChars; compile and store only on miss. Theregexpcompileinfunctionlinter exempts dynamic (non-constant) patterns, so no//nolintcomment is needed.Acceptance Criteria:
sanitizePatternCache sync.MapdeclaredapplySanitizePatternuses Load/Store pattern (no double-compile race)go test ./pkg/stringutil/...passesmake lintpassesTask 3: Convert
permissions_toolset_data.goinit() to lazy sync.OncePriority: Medium | Effort: Small
Code Region:
pkg/workflow/permissions_toolset_data.go,pkg/workflow/permissions_validation.go,pkg/workflow/github_toolsets.goRemove the
init()function. Addvar toolsetPermissionsOnce sync.Onceand a privategetToolsetPermissionsMap()accessor that runs the unmarshal+build logic lazily. Replace directtoolsetPermissionsMapreads inpermissions_validation.go:142andgithub_toolsets.go:78withgetToolsetPermissionsMap().Acceptance Criteria:
init()removed;sync.Oncelazy init addedtoolsetPermissionsMapgo through the accessorgo test ./pkg/workflow/...passesmake lintpassesTask 4: Add benchmark regression threshold to CI bench job
Priority: Medium | Effort: Medium
Code Region:
.github/workflows/cgo.ymlbench job (~line 906) — check for a.mdsource and update that instead, thenmake recompileInstall
benchstat(go install golang.org/x/perf/cmd/benchstat@latest), download the previous artifact (continue-on-error: true), runbenchstat old.txt new.txt, and fail the step if any benchmark's delta exceeds +20%. Upload new results as the artifact for future runs. If no previous artifact exists, skip comparison and just upload.Acceptance Criteria:
benchstatinstalled in bench jobcontinue-on-error: truebenchstatoutput added to step summaryTask 5: Eliminate redundant
knownRuntimesinit() insafe_update_enforcement.goPriority: Low | Effort: Small
Code Region:
pkg/workflow/safe_update_enforcement.go,pkg/workflow/runtime_definitions.gosafe_update_enforcement.gobuildsruntimeActionRepos map[string]boolininit().runtime_definitions.goalready buildsactionRepoToRuntime map[string]*Runtimecovering the same keys. ReplaceruntimeActionRepos[repo]checks withactionRepoToRuntime[repo] != nil, and removeruntimeActionReposand itsinit().Acceptance Criteria:
runtimeActionReposand itsinit()removed fromsafe_update_enforcement.goactionRepoToRuntime[repo] != nilinsteadgo test ./pkg/workflow/...passesmake lintpasses📊 Historical Context
Previous Focus Areas
📈 Success Metrics
Next Steps
References: §28241112820
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgSee Network Configuration for more information.
Beta Was this translation helpful? Give feedback.
All reactions