feat(core): enhance startup profiling with cross-process timing and UI milestones

This commit is contained in:
Sehoon Shon
2026-03-09 09:54:00 -04:00
parent 6c3a90645a
commit 2d79297847
5 changed files with 225 additions and 29 deletions
+16
View File
@@ -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.
+17 -1
View File
@@ -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
+9 -1
View File
@@ -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();