NLKNguyen / papercolor-theme

:art: Light & Dark Vim color schemes inspired by Google's Material Design
MIT License
2.71k stars 239 forks source link

Slow startup time #28

Closed pickfire closed 9 years ago

pickfire commented 9 years ago

I had found out that PaperColor Theme slows down the startup. Full log here: http://pastie.org/private/fpfzj8opftoqgsohpvng

2406.208  1777.571  1772.683: sourcing /home/ivan/.vim/plugged/papercolor-theme/colors/PaperColor.vim

I hope you can speed it up. Thanks.

NLKNguyen commented 9 years ago

I'm not familiar with this. I guess it's close to Tomorrow theme since I modified from it. How is the speed compared to other color schemes like Solarized or Gruvbox?

pickfire commented 9 years ago

I use base16, it seems like base16 is faster.

724.645  162.297  157.190: sourcing /home/ivan/.vim/plugged/base16-vim/colors/base16-solarized.vim

Just take a look at the third field.

pickfire commented 9 years ago

It seems it is even slower in neovim.

3038.269  2713.668  2705.840: sourcing /home/ivan/.nvim/plugged/papercolor-theme/colors/PaperColor.vim
NLKNguyen commented 9 years ago

How do you do the test?

q0LoCo commented 9 years ago

--startuptime? my result is 156ms and gruvbox only takes 35ms.

NLKNguyen commented 9 years ago

I mean, how do you get the number? what tool did you use so I can use to test?

pickfire commented 9 years ago

my result is 156ms and gruvbox only takes 35ms.

I am using Raspberry Pi 2, so that is why I am getting slow results.

You can do it with just:

vim --startuptime log.txt
:q
less log.txt

I mean, how do you get the number?

The numbers are actually in the log.txt file.

There is actually a vim plugin than can do this, but it seems that it is not working recently.

Another way:

http://usevim.com/2012/04/18/startuptime/

pickfire commented 9 years ago

I think the reason why papercolor is slow is because that it has 1000+ lines, base-16 only have 300+ lines and some random colorscheme I found is only about 100 lines.

NLKNguyen commented 9 years ago

Partly because of that, but more precisely, it's the number of function calls and string processing on each line of the design section. It's from Tomorrow theme, and the way it does is not necessary for PaperColor. I have some idea of how to make it load a lot faster. I'll do it sometime in the future.

pickfire commented 9 years ago

I suggest to look in base16 and jellybeans, I used base16 and found out that it have good startup time, which is about half of the time compared to papercolor. I suggest jellybeans because the author of vim-hybrid found out jellybeans have good colorscheme or something else.

morhetz commented 9 years ago

Hi, it seems that papercolor startup time is slowed down by functions computing terminal 256 palette fallbacks (CSApprox like behaviour). Dropping out " ctermfg=" . <SID>rgb(a:fg) and " ctermbg=" . <SID>rgb(a:bg) speeds up runtime from ~100ms to ~12ms. Gruvbox mean load time is ~50ms for me, so I should probably think about optimising at a bit too.

pickfire commented 9 years ago

I hope that it can just use True Colors if the terminal support truecolors.

Hi, it seems that papercolor startup time is slowed down by functions computing terminal 256 palette fallbacks (CSApprox like behaviour).

I am not sure about that, need to ask @NLKNguyen about it.

What do you mean Gruvbox?

morhetz commented 9 years ago

@pickfire gruvbox colorscheme average load time

pickfire commented 9 years ago

Gruvbox colorscheme have nice colour but it seems that the screenshot is not so good. And it seems too yellow for light colorscheme:

2015-08-31-115853_1600x900_scrot

Does gruvbox has support for true colors?

morhetz commented 9 years ago

@pickfire If you have gruvbox issues, please:

  1. read docs first
  2. open issue at gruvbox repo issues

It's not polite asking well known and documented questions at other project's issues.

pickfire commented 9 years ago

Sorry, but I hope @morhetz can fix this issue and create a pull request to @NLKNguyen.

NLKNguyen commented 9 years ago

@morhetz Thanks for pointing out :+1:. Since this colorscheme is based on 256-color (although there are still some leftover color codes from Tomorrow-theme), the programmatic conversion from true color to 256-color can be avoided.

I plan to do it manually by hand like this for example. It's essentially the fallback method you mentioned, except they are the same color by design.

let s:pink = ["#d7005f", 161]

Then use s:pink[0] for gui* and s:pink[1] for cterm* I will create a branch to work on this soon.

P.S. Thanks for you theme. I got help on light-dark-toggling from someone who studied your code :)

morhetz commented 9 years ago

@NLKNguyen Thanks :) PaperColor is very-very nice and heavily tuned. It's always а pleasure to read sources of thoroughly made colorscheme.

Then use s:pink[0] for gui* and s:pink[1] for cterm*

That's the way I've just roughly optimised gruvbox. Average load time dropped from ~50 to ~20. It's not release ready yet, but you could take some inspiration from s:HL function.

gist: gruvbox_optimised.vim

NLKNguyen commented 9 years ago

I just improved the speed. Apparently, it gets 7x speed up from ~100 to ~14 on my computer. Guys, please let me know how it performs on yours. @morhetz when yours is ready, I like to test Gruvbox startup speed on my computer as well.

pickfire commented 9 years ago

Wow, congratulations! I get 14x faster here.

Before:

3038.269  2713.668  2705.840: sourcing /home/ivan/.nvim/plugged/papercolor-theme/colors/PaperColor.vim

After:

801.110  195.138  190.100: sourcing /home/ivan/.vim/plugged/papercolor-theme/colors/PaperColor.vim

Do you think I should close this issue or you want it as a reminder?

NLKNguyen commented 9 years ago

Great haha :+1:

NLKNguyen commented 9 years ago

I'll close this after a few days in case of further discussion.

morhetz commented 9 years ago

@NLKNguyen it's 10.250 with papercolor vs 7.025 with gruvbox for me, and i doubt it matters :) though you could also pseudo-memoize common groups to hi! link CommonGroupName to decrease calculations, string concatenations time, etc.

NLKNguyen commented 9 years ago

Great! I just leave it like that for now since It's fast enough :D