mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 10:10:56 -07:00
feat(core): enhance startup profiling with cross-process timing and UI milestones
This commit is contained in:
@@ -328,6 +328,22 @@ export async function startInteractiveUI(
|
||||
export async function main() {
|
||||
const cliStartupHandle = startupProfiler.start('cli_startup');
|
||||
|
||||
const parentStartTime = process.env['GEMINI_CLI_PARENT_START_TIME'];
|
||||
if (parentStartTime) {
|
||||
const startAbsMs = parseInt(parentStartTime, 10);
|
||||
// Record how long the parent process(es) took before this child started.
|
||||
startupProfiler.recordPhase(
|
||||
'parent_process_duration',
|
||||
startAbsMs,
|
||||
performance.timeOrigin,
|
||||
);
|
||||
// Measure overall time from the very first process start
|
||||
startupProfiler.start('overall_startup', {}, startAbsMs);
|
||||
// Measure time from this child process launch
|
||||
startupProfiler.start('child_process_to_ui_visible');
|
||||
startupProfiler.start('child_process_to_typing_ready');
|
||||
}
|
||||
|
||||
// Listen for admin controls from parent process (IPC) in non-sandbox mode. In
|
||||
// sandbox mode, we re-fetch the admin controls from the server once we enter
|
||||
// the sandbox.
|
||||
|
||||
@@ -429,7 +429,6 @@ export const AppContainer = (props: AppContainerProps) => {
|
||||
await config.initialize();
|
||||
}
|
||||
setConfigInitialized(true);
|
||||
startupProfiler.flush(config);
|
||||
|
||||
const sessionStartSource = resumedSessionData
|
||||
? SessionStartSource.Resume
|
||||
@@ -2578,6 +2577,23 @@ Logging in with Google... Restarting Gemini CLI to continue.
|
||||
],
|
||||
);
|
||||
|
||||
const hasFlushedStartupRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (
|
||||
authState === AuthState.Authenticated &&
|
||||
!hasFlushedStartupRef.current
|
||||
) {
|
||||
startupProfiler.endPhase('child_process_to_typing_ready');
|
||||
startupProfiler.endPhase('overall_startup');
|
||||
startupProfiler.flush(config);
|
||||
hasFlushedStartupRef.current = true;
|
||||
}
|
||||
}, [authState, config]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
startupProfiler.endPhase('child_process_to_ui_visible');
|
||||
}, []);
|
||||
|
||||
if (authState === AuthState.AwaitingGoogleLoginRestart) {
|
||||
return (
|
||||
<LoginWithGoogleRestartDialog
|
||||
|
||||
@@ -55,7 +55,15 @@ export async function relaunchAppInChildProcess(
|
||||
...additionalScriptArgs,
|
||||
...scriptArgs,
|
||||
];
|
||||
const newEnv = { ...process.env, GEMINI_CLI_NO_RELAUNCH: 'true' };
|
||||
|
||||
const parentStartTime =
|
||||
process.env['GEMINI_CLI_PARENT_START_TIME'] || Date.now().toString();
|
||||
|
||||
const newEnv = {
|
||||
...process.env,
|
||||
GEMINI_CLI_NO_RELAUNCH: 'true',
|
||||
GEMINI_CLI_PARENT_START_TIME: parentStartTime,
|
||||
};
|
||||
|
||||
// The parent process should not be reading from stdin while the child is running.
|
||||
process.stdin.pause();
|
||||
|
||||
Reference in New Issue
Block a user