Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher benchmarks in Vim's startuptime #666

Closed
weirdsmiley opened this issue Jul 17, 2023 · 6 comments
Closed

Higher benchmarks in Vim's startuptime #666

weirdsmiley opened this issue Jul 17, 2023 · 6 comments

Comments

@weirdsmiley
Copy link

I am using hyperfine 1.17.0 to test vim's startup time. And the results are almost 2s more than what time or vim --startuptime startuptime.log are showing. I have tried not spawing the shell (-N), not loading any vim plugins, features etc. but still these benchmarks are persistent.

$ hyperfine "vim -N -u NONE -i NONE -X -cq"
Benchmark 1: vim -N -u NONE -i NONE -X -cq
  Time (mean ± σ):      2.048 s ±  0.005 s    [User: 0.027 s, System: 0.016 s]
  Range (min … max):    2.042 s …  2.055 s    10 runs

$ time vim -N -u NONE -i NONE -X -cq

real    0m0.034s
user    0m0.020s
sys     0m0.014s

vim --startuptime startuptime.log also shows smaller number than hyperfine (note: this loads the plugins). A detailed log is here.

Also, strace shows a similar picture as time with systime being at around 10ms. Detailed log is here.

@sharkdp
Copy link
Owner

sharkdp commented Jul 17, 2023

Hm, interesting. Thank you for reporting this. Can you please try with --output=inherit. Maybe vim is doing something different if it doesn't detect an interactive terminal.

@sharkdp
Copy link
Owner

sharkdp commented Jul 17, 2023

Something weird is definitely going on

▶ vim -N -u NONE -i NONE -X -cq > /dev/null
▶ echo $?
0

▶ vim -N -u NONE -i NONE -X -cq            
[prints some garbage to the terminal]
▶ echo $?                       
1

@sharkdp
Copy link
Owner

sharkdp commented Jul 17, 2023

Oh wait, vim is neovim for me. With plain VIM, I can reproduce this. The problem seems to be STDIN, not STDOUT. Try running

time vim -N -u NONE -i NONE -X -cq < /dev/null

and you should see the same behavior with time.

Vim is printing a warning (Input is not from a terminal), and then exiting after 2s.

@sharkdp
Copy link
Owner

sharkdp commented Jul 17, 2023

Look at this: here are the mysterious 2 seconds (actually 2005 ms, to be precise): https://github.com/vim/vim/blob/4c0089d696b8d1d5dc40568f25ea5738fa5bbffb/src/main.c#L2802-L2807

@sharkdp
Copy link
Owner

sharkdp commented Jul 17, 2023

I think you can maybe add -s /dev/null to fix it. But not sure if that's what you really want to benchmark.

▶ hyperfine -N 'vim.basic -N -u NONE -i NONE -X -cq -s /dev/null'
Benchmark 1: vim.basic -N -u NONE -i NONE -X -cq -s /dev/null
  Time (mean ± σ):       4.1 ms ±   1.3 ms    [User: 2.1 ms, System: 1.8 ms]
  Range (min … max):     2.5 ms …   7.8 ms    382 runs

@weirdsmiley
Copy link
Author

Look at this: here are the mysterious 2 seconds (actually 2005 ms, to be precise): https://github.com/vim/vim/blob/4c0089d696b8d1d5dc40568f25ea5738fa5bbffb/src/main.c#L2802-L2807

Wow! Let me take this info to the mailing list.

I think you can maybe add -s /dev/null to fix it. But not sure if that's what you really want to benchmark.

Yes, this helps. Now it is much more accurate (as compared to time and --startuptime).

Thanks a lot! I am closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants