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

Performance regression when opening Ansible YAML files #529

Closed
ybc37 opened this issue Aug 26, 2020 · 6 comments
Closed

Performance regression when opening Ansible YAML files #529

ybc37 opened this issue Aug 26, 2020 · 6 comments

Comments

@ybc37
Copy link

ybc37 commented Aug 26, 2020

First, thanks for vim-polyglot! 😄

Does this bug happen when you install plugin without vim-polyglot? No

Describe the bug:
With the latest ftdetect changes/refactoring, Ansible (YAML) files take too long to open (~5s on my machine, but without measuring it precisely). Maybe related: #518

To Reproduce:
Open a YAML file in an Ansible project. I don't have a public repo, but used Arch Linux infra repo to reproduce:

  1. git clone https://gitlab.archlinux.org/archlinux/infrastructure.git && cd infrastructure
  2. nvim roles/common/tasks/main.yml
@sheerun
Copy link
Owner

sheerun commented Aug 26, 2020

It loads immediately for me. Could you please attach load logs produced with:

nvim roles/common/tasks/main.yml --startuptime startup.log

@ybc37
Copy link
Author

ybc37 commented Aug 26, 2020

Thanks for checking @sheerun!

You're right, after disabling all plugins but vim-polyglot it starts immediately. Turns out it only occurs when vim-sleuth is enabled. I'm not sure whats wrong, but still, before creating this issue I checked without vim-polyglot and only ansible-vim and that worked. So I wonder what's the root of this (vim-sleuth or vim-polyglot). Maybe they just don't play well together :)

Anyway I attache the startup log with only vim-polyglot and vim-sleuth enabled:
startup.log

Edit: formatting, typo

@sheerun
Copy link
Owner

sheerun commented Aug 26, 2020

vim-sleuth is really slow so it's not in my plugins as well. I guess it's because new setup doesn't setup shiftwidth and expandtab manually so sleuth tries to detect it which is really slow. I'll check this, but I suggest you just remove sleuth

@ybc37
Copy link
Author

ybc37 commented Sep 1, 2020

The weird thing is that I the performance only drops, if both plugins are enabled. If I disable vim-polyglot, vim-sleuth doesn't cause such performance issues.

I can also reproduce the same behavior with a package.json in one of my projects, but it's not a general issue with json files.

vim-sleuth may be a bit slow, but still is really helpful in projects without Editorconfig or similar 😉

Maybe I find some time soon to debug it and get more details.

@sheerun
Copy link
Owner

sheerun commented Sep 1, 2020

It seems to be because

a) surprisingly vim-sleuth is able to detect only 8-characters-long soft tabs which is why it fails to detect softtabs for yaml file which has no lines indented with less than 8 spaces
b) if vim-sleuth fails to detect soft tabs in current files, it tries other files of the same filetype. to do so it reads autocommands table which is very long if you use vim-polyglot
c) them sleuth does the same for each of neighboring files

I think the best solution is to embed optimized version of sleuth in vim-polyglot

@sheerun sheerun closed this as completed in 63119f0 Sep 1, 2020
@ybc37
Copy link
Author

ybc37 commented Sep 2, 2020

Thank @sheerun! I didn't expect this and I really appreciate it! As far as I can tell, it works like a charm 😄

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