Draft
perf: cache builtin alias map and DFS cycle-check to fix CompileMCPWorkflow regression#44996
Conversation
…Workflow speedup Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix regression in CompileMCPWorkflow performance
perf: cache builtin alias map and DFS cycle-check to fix CompileMCPWorkflow regression
Jul 11, 2026
Contributor
🤖 PR Triage
Draft PR — part of perf regression batch. Review together with #44994 and #44995.
|
This was referenced Jul 11, 2026
Open
Contributor
🤖 PR Triage
Rationale: Draft. Caches builtin alias map and DFS cycle-check to fix CompileMCPWorkflow +14% regression. Small change. Batch with other perf PRs. Triage run §29183606049
|
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.
BenchmarkCompileMCPWorkflowregressed +14% (432µs vs 379µs). Two hot paths were doing redundant work on every compilation:BuiltinModelAliases()deep-copied the 52-entry builtin map on every call, anddetectCircularModelAliasesran a full DFS over all 52 builtin keys even though builtins are immutable and cycle-free.model_aliases.gobuiltinOnlyAliasMap()backed bysync.Oncereturning a cached shared reference to the merged builtin mapMergeImportedModelAliases(nil, nil)— the common case for MCP workflows with no imports — now returns the cached reference instead of deep-copyingmodel_alias_validation.godetectCircularModelAliasesuses a newisBuiltinOnlyAliasMaphelper (key-set equality, not just length) to detect when the input is the builtin-only mapsync.Onceand the result is cached for all subsequent callsloadBuiltinModelAliases()errors are now logged with a fallback to full DFS instead of being silently discardedmarkdownPathto avoid embedding a stale caller path in a shared errorResult: ~291–306µs vs reported 432µs (~30% faster); 80 fewer allocs/op, ~10KB less memory per compilation.