elixir-tools / elixir-tools.nvim

Neovim plugin for Elixir
MIT License
413 stars 31 forks source link

How to troubleshoot extremely slow startup? #219

Closed dfalling closed 2 months ago

dfalling commented 3 months ago

I tracked down my very slow nvim launch time to requiring the elixir package:

vim file --startuptime log

...
066.620  000.361: inits 3
069.277  002.657: reading ShaDa
071.248  000.261  000.261: require('vim.iter')
072.756  000.496  000.496: require('plenary.bit')
072.954  000.197  000.197: require('plenary.functional')
072.975  001.452  000.760: require('plenary.path')
073.688  000.133  000.133: require('plenary.strings')
073.690  000.383  000.250: require('plenary.window.border')
073.892  000.202  000.202: require('plenary.window')
074.257  000.364  000.364: require('plenary.popup.utils')
074.260  001.284  000.335: require('plenary.popup')
074.660  000.399  000.399: require('elixir.elixirls.version')
075.656  000.233  000.233: require('plenary.compat')
075.662  000.756  000.524: require('plenary.job')
076.062  000.399  000.399: require('elixir.utils')
076.063  001.402  000.246: require('elixir.elixirls.download')
076.474  000.409  000.409: require('elixir.elixirls.compile')
077.734  006.485  001.538: require('elixir.elixirls')
078.096  000.360  000.360: require('elixir.credo')
078.312  000.215  000.215: require('elixir.nextls')
079.150  000.178  000.178: require('elixir.mix.git')
079.151  000.363  000.185: require('elixir.mix.exs')
079.152  000.649  000.286: require('elixir.mix.wrapper')
079.154  000.840  000.192: require('elixir.mix')
079.380  000.225  000.225: require('elixir.projectionist')
079.387  009.617  001.231: require('elixir')
2630.997  001.809  001.809: require('vim.filetype')

I'm importing it via:

  {
    "elixir-tools/elixir-tools.nvim",
    version = "*",
    event = { "BufReadPre", "BufNewFile" },
    config = function()
      local elixir = require("elixir")
      local elixirls = require("elixir.elixirls")

      elixir.setup {
        nextls = {enable = true},
        credo = {},
        elixirls = {enable = false,}
      }
    end,
    dependencies = {
      "nvim-lua/plenary.nvim",
    },
  },

Any tips on further tracking down what I've screwed up to make it load so slowly?

Thanks!

mhanberg commented 3 months ago

can you open a file like nvim lib/some_file.ex and then see what :Lazy profile says for elixir-tools.nvim ?

For me it says 0.91ms.

Also, try explicitly disabled credo language server

dfalling commented 2 months ago

Strangely it's been very slow on non-Elixir files as well (eg opening my .gitconfig.) I think it may be network-related, as I have good WiFi for the first time in weeks and it's snappy again:

elixir-tools.nvim 282.19ms

Disabling credo got it down: elixir-tools.nvim 5.21ms

I'll profile it again when it's slow again.

dfalling commented 2 months ago

I have mediocre wifi now, and the startup time is ramping back up:

    ●  BufReadPre 884ms
      ➜  elixir-tools.nvim 883.79ms
dfalling commented 2 months ago
    ●  BufReadPre 1319.58ms
      ➜  elixir-tools.nvim 1319.54ms

So it's definitely very network dependent. All my other packages don't seem to be affected the same way. Is there something I can do to disable this network dependency?

mhanberg commented 2 months ago

Is credo still disabled? there shouldn't be anything else that hits the network

dfalling commented 2 months ago

Ah good call, I had re-enabled it. Is there any way to keep Credo from hitting the network? Disabling it definitely resolves the lag though I'd love to be able to use it.

mhanberg commented 2 months ago

If you are using Next LS, then it already comes with credo integration, so you don't need to use it.

dfalling commented 2 months ago

Perfect, thank you!