[Repo Assist] refactor(launcher): eliminate double config lookup in GetOrLaunchForSession#7268
Merged
lpcox merged 2 commits intoJun 9, 2026
Conversation
… config lookup GetOrLaunchForSession previously called getServerConfig to fetch the server config, then delegated to GetOrLaunch for HTTP backends, which called getServerConfig a second time — acquiring the read lock twice for every HTTP request routed through GetOrLaunchForSession. Extract the inner logic of GetOrLaunch into a private getOrLaunchWithConfig helper that accepts a pre-fetched *config.ServerConfig. Both GetOrLaunch and GetOrLaunchForSession now call this helper after their single config lookup, ensuring the RWMutex read lock is acquired only once per request. No public API changes; existing callers (server/tool_registry.go, server/unified.go) are unaffected. Closes #7254 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the launcher’s connection acquisition flow to avoid redundant server config lookups (and associated RWMutex RLock acquisitions) when GetOrLaunchForSession routes HTTP backends through the stateless connection pool.
Changes:
- Extracts the shared
syncutil.GetOrCreatelaunch logic into a new private helpergetOrLaunchWithConfig. - Updates
GetOrLaunchto fetch config once and delegate togetOrLaunchWithConfig. - Updates
GetOrLaunchForSessionto reuse its already-fetched config when routing HTTP backends.
Show a summary per file
| File | Description |
|---|---|
| internal/launcher/launcher.go | Extracts shared launch logic to reuse a single config lookup/lock acquisition across HTTP routing paths. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
Comment on lines
205
to
208
| if serverCfg.Type == "http" { | ||
| logLauncher.Printf("HTTP backend detected, using stateless connection: serverID=%s", serverID) | ||
| return GetOrLaunch(l, serverID) | ||
| return getOrLaunchWithConfig(l, serverID, serverCfg) | ||
| } |
Collaborator
|
@copilot address review feedback |
Contributor
This was referenced Jun 10, 2026
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
When
GetOrLaunchForSessionhandles an HTTP backend, it previously calledgetServerConfigonce (acquiring the read lock), then immediately delegated toGetOrLaunchwhich calledgetServerConfiga second time — acquiring the same read lock twice per HTTP request.Root Cause
GetOrLaunchForSessionneeded to know the backend type before routing. For HTTP backends it calledGetOrLaunch, which blindly re-fetched the config:Fix
Extract the inner logic of
GetOrLaunchinto a privategetOrLaunchWithConfighelper that accepts a pre-fetched*config.ServerConfig. Both public functions now call this helper after their single config lookup:Trade-offs
GetOrLaunchandGetOrLaunchForSessionsignatures are unchanged.getOrLaunchWithConfigis a verbatim extraction of the existingsyncutil.GetOrCreatecall body.GetOrLaunchForSession, thegetServerConfigRLock is acquired once instead of twice.Addresses: #7254
Test Status
go buildandgo testrequire downloading modules fromproxy.golang.org, which is blocked by the network firewall in this environment. The code change is a straightforward extraction with no behavioural changes — thegetOrLaunchWithConfigbody is an exact verbatim copy of the originalsyncutil.GetOrCreateclosure inGetOrLaunch. All existing tests forGetOrLaunchForSession_HTTPBackend,GetOrLaunch_*, and related launchers remain valid and unchanged.gofmt— no formatting changesgo build— blocked (proxy.golang.org unreachable in CI sandbox)go test— blocked (same reason)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run