mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-15 14:23:02 -07:00
perf(core): parallelize tool discovery and background IDE client to speed up initialization
This commit is contained in:
@@ -105,6 +105,9 @@ describe('initializer', () => {
|
||||
mockSettings,
|
||||
);
|
||||
|
||||
// Wait for the background promise to resolve
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
expect(result).toEqual({
|
||||
authError: null,
|
||||
accountSuspensionInfo: null,
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
StartSessionEvent,
|
||||
logCliConfiguration,
|
||||
startupProfiler,
|
||||
debugLogger,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { type LoadedSettings } from '../config/settings.js';
|
||||
import { performInitialAuth } from './auth.js';
|
||||
@@ -55,9 +56,18 @@ export async function initializeApp(
|
||||
);
|
||||
|
||||
if (config.getIdeMode()) {
|
||||
const ideClient = await IdeClient.getInstance();
|
||||
await ideClient.connect();
|
||||
logIdeConnection(config, new IdeConnectionEvent(IdeConnectionType.START));
|
||||
IdeClient.getInstance()
|
||||
.then(async (ideClient) => {
|
||||
await ideClient.connect();
|
||||
logIdeConnection(
|
||||
config,
|
||||
new IdeConnectionEvent(IdeConnectionType.START),
|
||||
);
|
||||
})
|
||||
.catch((e) => {
|
||||
// We log locally if IDE connection setup fails in the background.
|
||||
debugLogger.error('Failed to initialize IDE client:', e);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1288,18 +1288,27 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
// Initialize centralized FileDiscoveryService
|
||||
const discoverToolsHandle = startupProfiler.start('discover_tools');
|
||||
this.getFileService();
|
||||
|
||||
const discoveryPromises: Array<Promise<unknown>> = [];
|
||||
|
||||
if (this.getCheckpointingEnabled()) {
|
||||
await this.getGitService();
|
||||
discoveryPromises.push(this.getGitService());
|
||||
}
|
||||
|
||||
this._promptRegistry = new PromptRegistry();
|
||||
this._resourceRegistry = new ResourceRegistry();
|
||||
|
||||
this.agentRegistry = new AgentRegistry(this);
|
||||
await this.agentRegistry.initialize();
|
||||
discoveryPromises.push(this.agentRegistry.initialize());
|
||||
|
||||
coreEvents.on(CoreEvent.AgentsRefreshed, this.onAgentsRefreshed);
|
||||
|
||||
this._toolRegistry = await this.createToolRegistry();
|
||||
const toolRegistryPromise = this.createToolRegistry().then((registry) => {
|
||||
this._toolRegistry = registry;
|
||||
});
|
||||
discoveryPromises.push(toolRegistryPromise);
|
||||
|
||||
await Promise.all(discoveryPromises);
|
||||
discoverToolsHandle?.end();
|
||||
this.mcpClientManager = new McpClientManager(
|
||||
this.clientVersion,
|
||||
|
||||
Reference in New Issue
Block a user