lewis6991 / impatient.nvim

Improve startup time for Neovim
MIT License
1.19k stars 28 forks source link

`pcall(require, <missing module>)` takes a long time #20

Closed goolord closed 2 years ago

goolord commented 3 years ago

ref: https://github.com/lukas-reineke/indent-blankline.nvim/pull/213

tldr; a piece of code like this

local ts_status, ts_query = pcall(require, "nvim-treesitter.query")
local ts_status, ts_indent = pcall(require, "nvim-treesitter.indent")

is about 366% slower (~6 ms -> ~22 ms) with impatient.nvim enabled when nvim-treesitter, nvim-treesitter.query, and nvim-treesitter.indent don't exist

chase commented 3 years ago

Hm, so the nvim-treesitter module isn't located anywhere in your runtime path?

If this is a regular case where a module doesn't exist, might need to figure out how to do a faster fall-through. Maybe add a loader at the very end that records missing packages and checks ahead of loading the cache if the file exists, or something similar.

lewis6991 commented 3 years ago

It is probably because we maintain the original vim loader, and we add 3 of our own.

One solution would be to just remove neovims original loader.

Maybe add a loader at the very end that records missing packages and checks ahead of loading the cache if the file exists, or something similar.

Interesting idea, we could do that. Problem is I'm not sure how to bail the loading process and skip all the loaders. Maybe redefining require?

lewis6991 commented 3 years ago

@goolord can you give #24 a go. It should make the performance roughly the same as without impatient for loading missing modules.

lewis6991 commented 2 years ago

Fixed with #46