Reduce BenchmarkValidation latency by caching permission-scope validation#35076
Merged
Conversation
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix performance regression in BenchmarkValidation
Reduce May 26, 2026
BenchmarkValidation latency by caching permission-scope validation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a performance regression in the workflow validation hot path by caching the result of permission-scope name validation on WorkflowData, so repeated validation passes don’t re-parse permissions YAML.
Changes:
- Cache
ValidatePermissionScopeNames(...)result inCompiler.applyDefaultsviaWorkflowData.CachedPermissionScopeNamesErr+CachedPermissionScopeNamesSet. - Update
Compiler.validatePermissionsto reuse the cached permission-scope validation result when available, with a fallback for directWorkflowDataconstruction paths. - Add a unit test ensuring the cached validation result is honored.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/tools.go | Populates the cached permission-scope validation result during applyDefaults. |
| pkg/workflow/permissions_compiler_validator.go | Reuses cached permission-scope validation result in validatePermissions when set. |
| pkg/workflow/compiler_validators_test.go | Adds a targeted test asserting validatePermissions uses the cached result. |
| pkg/workflow/compiler_types.go | Adds cached permission-scope validation fields to WorkflowData. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BenchmarkValidationregressed significantly in the validation pipeline. The hot path was repeatedly re-validating permission scope names from YAML on each validation pass, adding avoidable parse and allocation overhead.Root cause in validation hot path
validatePermissionsalways calledValidatePermissionScopeNames(workflowData.Permissions), even whenWorkflowDatahad already been normalized and cached inapplyDefaults.Caching added to
WorkflowDataCachedPermissionScopeNamesErrCachedPermissionScopeNamesSetapplyDefaults, alongside other existing compiler caches.Validator now reuses cached result
validatePermissionsnow:Targeted regression guard
validatePermissionsconsumes cached permission-scope validation results when set.