Closed maximbaz closed 5 years ago
In my view, lazy loading is the last resort, I'd much rather ensure that we are quick to load even without.
@mawww one issue with even super fast script/module loading is - bloat. Sometimes I'm just editing a git commit, or a text file; I really don't want to see arbitrary clang completions or rust commands when pressing :
.
I'd much prefer to see something like @laelath described above, where the editor loads lang specific stuff only in buffers (or clients) when a file of that kind is open. Loading & caching per session would also keep the bloat problem.
@supermarin I am not sure that hidden bloat would be less bloat, lazy loading to hide those functions means we now need to guess if the users needs them or not. sometimes its easy (clang-complete is unlikely to be needed if we have no buffer whose filetype is c, cpp or objc), sometimes less so (we are in tmux, would it make sense to provide a way to open a x11 window as well, or not ?)
It is possible for users to disable scripts they do not need, and it is possible to write their own lazy loading hooks relatively easily. The missing part is a way to autoload dependencies, to avoid putting on users the burden of knowing what depends on what.
This is fixed in master
by lazy loading implemented by @laelath in https://github.com/mawww/kakoune/pull/2782, thanks a lot everyone!
The final numbers:
nvim with no config: 25ms
❯ time (repeat 100 nvim -u NONE -c 'quit')
1.33s user 0.87s system 88% cpu 2.490 total
nvim with huge config and lots of plugins: 114ms
❯ time (repeat 100 nvim -c 'quit')
9.20s user 1.61s system 94% cpu 11.390 total
kak -n: 7ms
❯ time (repeat 100 kak -n -e 'quit')
0.35s user 0.35s system 99% cpu 0.703 total
kak with no custom config in v2019.01.20
: 70ms
❯ time (repeat 100 kak -e 'quit')
7.11s user 1.91s system 115% cpu 7.812 total
kak with no custom config in master
: 20ms
❯ time (repeat 100 kak -e 'quit')
1.77s user 0.72s system 120% cpu 2.060 total
20ms beats neovim's 25ms, the issue is solved 🙂
kakoune is indeed plenty fast when started with no config (kak -n
), however when starting with a few plugins, it is way more slower than my nvim config with more plugins. :thinking:
kakoune with a few plugins:
❯ time (repeat 100 kak -e 'quit')
( repeat 100; do; kak -e 'quit'; done; ) 59.99s user 23.15s system 103% cpu 1:20.35 total
nvim with a bigger config and more plugins:
❯ time (repeat 100 nvim -c 'quit')
( repeat 100; do; nvim -c 'quit'; done; ) 6.84s user 0.90s system 97% cpu 7.961 total
I guess nvim greatly improved loading speed for heavy configs since 2019
It is remarkable however that kakoune is faster than nvim with no config:
❯ time (repeat 100 kak -n -e 'quit')
( repeat 100; do; kak -n -e 'quit'; done; ) 0.21s user 0.19s system 100% cpu 0.400 total
❯ time (repeat 100 nvim -u NONE -c 'quit')
( repeat 100; do; nvim -u NONE -c 'quit'; done; ) 1.20s user 0.48s system 85% cpu 1.972 total
I wonder what it would take to improve loading time when using plugins
Would be helpful to know which / how many plugins you're using.
edit: or even better, a full profile of startup time. You can get that by running kak -debug 'profile|shell' -e 'b *debug* ; write profile ; quit'
Hi! Sure,
I just came back to kakoune after using neovim for a while, I'm currently updating my config and just pushed my current changes for reference.
Here is a profile I got with your command: profile.txt
Most of the time is indeed spent in the plugins.kak file:
sourcing '/home/auroden/.config/kak/plugins.kak' took 477831 us
Not sure if it's still the case, but from experience andreyorst's plug.kak tends to be pretty slow on startup because it calls the shell on every plug
command. You could probably speed it up a bit by setting your KAKOUNE_POSIX_SHELL
to dash
, which is known to be real fast.
Also, have you tried alexherbo2's plugin manager? It shouldn't have this issue at all
Thank you SeerLite, I'll try that!
I was able to get better performance using alexherbo2's plugin manager :+1:
❯ time (repeat 100 kak -e 'quit')
( repeat 100; do; kak -e 'quit'; done; ) 24.58s user 2.74s system 134% cpu 20.344 total
Still slower, but there is a limit to what can be done performance-wise with kakoune plugin model.
Install
kakoune
on Arch Linux from the official repo.Run
kak -n
— kakoune starts instantly (perfect). Runkak
— kakoune starts noticeably slowly, even though I didn't even create~/.config/kak/
folder yet. I useneovim
with lots of plugins and huge config file, and it starts faster thankak
.Given that I open and close editor many times during the day, it is essential to have the editor start as fast as possible.
I'm not sure how I can provide more information to narrow down the cause of slowness. What does
kak
do, thatkak -n
doesn't?