Skip to content

perf: speed up model switcher credential discovery#3673

Merged
rumpl merged 1 commit into
docker:mainfrom
rumpl:perf-model-switcher-credentials
Jul 16, 2026
Merged

perf: speed up model switcher credential discovery#3673
rumpl merged 1 commit into
docker:mainfrom
rumpl:perf-model-switcher-credentials

Conversation

@rumpl

@rumpl rumpl commented Jul 15, 2026

Copy link
Copy Markdown
Member

Opening the model picker checked every provider credential sequentially. Missing environment variables fall through the secret-provider chain and can spawn a macOS Keychain lookup for each key, causing a multi-second delay before the model picker opened.

Deduplicate credential names and resolve the independent lookups concurrently before filtering catalog providers. This preserves the existing provider availability checks while substantially reducing model-picker latency.

On my machine this went from ~3 second for the model switcher to open to about <1s, it's still not great but not sure what else we can do

Opening the model picker checked every provider credential sequentially. Missing environment variables fall through the secret-provider chain and can spawn a macOS Keychain lookup for each key, causing a multi-second delay before the model picker opened.

Deduplicate credential names and resolve the independent lookups concurrently before filtering catalog providers. This preserves the existing provider availability checks while substantially reducing model-picker latency.

Signed-off-by: Djordje Lukic <[email protected]>
@rumpl
rumpl requested a review from a team as a code owner July 15, 2026 21:44
@rumpl
rumpl enabled auto-merge July 15, 2026 21:44

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The concurrent credential pre-fetch is implemented correctly. The lookupEnvironmentValues helper properly deduplicates names before spawning goroutines, uses a thread-safe concurrent.Map for writes, and drains all goroutines via wg.Wait() before the result map is built. No data races, goroutine leaks, or correctness issues were found in the new code.

Reviewed: pkg/runtime/model_switcher.go — concurrent credential discovery refactor

@aheritier aheritier added kind/refactor PR refactors code without behavior change area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection labels Jul 15, 2026
@rumpl
rumpl merged commit cdedcf5 into docker:main Jul 16, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants