-
Notifications
You must be signed in to change notification settings - Fork 454
Reduce CompileMCPWorkflow overhead by caching runtime requirement detection per compile #43833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pelikhan
merged 5 commits into
main
from
copilot/performance-regression-fix-compile-mcp-workflow
Jul 7, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d1aca4a
Initial plan
Copilot 6a1ab36
Cache runtime requirements across compile validation and YAML generation
Copilot ffdd7b1
Merge remote-tracking branch 'origin/main' into copilot/performance-r…
Copilot cf66986
Fix runtime cache defensive copy coverage
Copilot 5fb2e78
Merge branch 'main' into copilot/performance-regression-fix-compile-m…
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| //go:build !integration | ||
|
|
||
| package workflow | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestDetectRuntimeRequirementsCached_NilWorkflowData(t *testing.T) { | ||
| require.Nil(t, detectRuntimeRequirementsCached(nil), "nil workflow data should produce no runtime requirements") | ||
| } | ||
|
|
||
| func TestDetectRuntimeRequirementsCached_EmptyRequirements(t *testing.T) { | ||
| workflowData := &WorkflowData{} | ||
|
|
||
| result := detectRuntimeRequirementsCached(workflowData) | ||
|
|
||
| require.Empty(t, result, "workflow without runtime inputs should produce no runtime requirements") | ||
| require.True(t, workflowData.CachedRuntimeRequirementsSet, "empty detection result should still mark the cache as populated") | ||
| require.Nil(t, workflowData.CachedRuntimeRequirements, "empty detection result should be cached as nil requirements") | ||
| } | ||
|
|
||
| func TestDetectRuntimeRequirementsCached_CacheMissReturnsIndependentCopy(t *testing.T) { | ||
| workflowData := &WorkflowData{ | ||
| CustomSteps: "run: node --version", | ||
| } | ||
|
|
||
| first := detectRuntimeRequirementsCached(workflowData) | ||
|
pelikhan marked this conversation as resolved.
|
||
| require.NotEmpty(t, first, "cache miss should still return detected runtime requirements") | ||
| require.True(t, workflowData.CachedRuntimeRequirementsSet, "cache miss should populate the runtime requirement cache") | ||
|
|
||
| first[0].Version = "mutated-version" | ||
| require.NotEqual(t, "mutated-version", workflowData.CachedRuntimeRequirements[0].Version, "mutating the first cache-miss result must not corrupt the cached requirements") | ||
|
|
||
| second := detectRuntimeRequirementsCached(workflowData) | ||
| require.NotEmpty(t, second, "subsequent cache hits should still return runtime requirements") | ||
| require.NotEqual(t, "mutated-version", second[0].Version, "cache-hit result should not observe mutation from the cache-miss return value") | ||
| } | ||
|
|
||
| func TestDetectRuntimeRequirementsCached_CacheHitReturnsDeepCopy(t *testing.T) { | ||
| workflowData := &WorkflowData{ | ||
| CachedRuntimeRequirements: []RuntimeRequirement{ | ||
| { | ||
| Runtime: findRuntimeByID("node"), | ||
| Version: "24", | ||
| ExtraFields: map[string]any{ | ||
| "cache": "npm", | ||
| }, | ||
| }, | ||
| }, | ||
| CachedRuntimeRequirementsSet: true, | ||
| } | ||
|
|
||
| first := detectRuntimeRequirementsCached(workflowData) | ||
| require.Len(t, first, 1, "cache hit should return the cached runtime requirements") | ||
|
|
||
| first[0].Version = "mutated-version" | ||
|
pelikhan marked this conversation as resolved.
|
||
| first[0].ExtraFields["cache"] = "mutated-cache" | ||
|
|
||
| require.Equal(t, "24", workflowData.CachedRuntimeRequirements[0].Version, "mutating a cache-hit result must not change the cached version") | ||
| require.Equal(t, "npm", workflowData.CachedRuntimeRequirements[0].ExtraFields["cache"], "mutating a cache-hit result must not change cached extra fields") | ||
|
|
||
| second := detectRuntimeRequirementsCached(workflowData) | ||
| require.Len(t, second, 1, "subsequent cache hits should continue to return one cached runtime requirement") | ||
| require.Equal(t, "24", second[0].Version, "subsequent cache hits should return the original cached version") | ||
| require.Equal(t, "npm", second[0].ExtraFields["cache"], "subsequent cache hits should return a deep-cloned extra-fields map") | ||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.