mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
fix(startup): multiprocess startuptime #26790
Problem:
Since 2448816956
, the --startuptime report shows
two blocks of data. The TUI process and its embedded nvim process write to the
file concurrently, which may interleave the two startup sequences into the same
timeline.
Solution:
Report each process as a separate section in the same file.
1. Each process buffers the full report.
2. After startup is finished, the buffer is flushed (appended) to the file.
Fix #23036
Sample report:
--- Startup times for process: Primary/TUI ---
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.006 000.006: --- NVIM STARTING ---
000.428 000.422: event init
000.728 000.301: early init
...
005.880 000.713: init highlight
005.882 000.002: --- NVIM STARTED ---
--- Startup times for process: Embedded ---
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.006 000.006: --- NVIM STARTING ---
000.409 000.403: event init
000.557 000.148: early init
000.633 000.077: locale set
...
014.383 000.430: first screen update
014.387 000.003: --- NVIM STARTED ---
This commit is contained in:
@@ -399,6 +399,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (ui_client_channel_id) {
|
||||
time_finish();
|
||||
ui_client_run(remote_ui); // NORETURN
|
||||
}
|
||||
assert(!ui_client_channel_id && !use_builtin_ui);
|
||||
@@ -695,6 +696,9 @@ void getout(int exitval)
|
||||
assert(!ui_client_channel_id);
|
||||
exiting = true;
|
||||
|
||||
// make sure startuptimes have been flushed
|
||||
time_finish();
|
||||
|
||||
// On error during Ex mode, exit with a non-zero code.
|
||||
// POSIX requires this, although it's not 100% clear from the standard.
|
||||
if (exmode_active) {
|
||||
@@ -1495,9 +1499,16 @@ static void init_params(mparm_T *paramp, int argc, char **argv)
|
||||
/// Initialize global startuptime file if "--startuptime" passed as an argument.
|
||||
static void init_startuptime(mparm_T *paramp)
|
||||
{
|
||||
bool is_embed = false;
|
||||
for (int i = 1; i < paramp->argc - 1; i++) {
|
||||
if (STRICMP(paramp->argv[i], "--embed") == 0) {
|
||||
is_embed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < paramp->argc - 1; i++) {
|
||||
if (STRICMP(paramp->argv[i], "--startuptime") == 0) {
|
||||
time_fd = fopen(paramp->argv[i + 1], "a");
|
||||
time_init(paramp->argv[i + 1], is_embed ? "Embedded" : "Primary/TUI");
|
||||
time_start("--- NVIM STARTING ---");
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user